I've tried to limit this list to advertised sites; there are others that I run across occasionally, but their URLs tend to vary over time, so it isn't a good idea to place them in a static document such as this one. It makes for a short list, though.
:se tagprg="global -t $1"
Once you have run global's
gtags
utility, you can do some powerful things such as
search for each place where a function (e.g., m_front()) is called, like this:
:ta -r m_front
elvisemx.exe
)
or "x11" (elvisx11.exe
) versions of Elvis under OS/2.
You can use Elvis as a light-weight Web browser. Surfing with Elvis isn't as much fun as surfing with a multimedia-capable browser such as Netscape or MSIE, but Elvis does have some advantages: it starts up much faster, it feels like vi, and you can edit whatever you download.
There's no special trick to loading a Web page. Just give a URL where Elvis expects a filename, and Elvis will read the Web page via the Internet. You can follow links in Web pages just as you do in Elvis' online manual. HTML pages are displayed in the "html" display mode, and anything else uses the "hex" or "normal" display mode by default. All data is fetched in binary so data files aren't mangled; however, this also means that newlines aren't converted, which may make non-HTML text files look ugly.
Elvis has built-in support for the HTTP and FTP protocols. Other protocols may be indirectly supported, via an HTTP proxy as indicated by the elvis.net configuration file.
By default, FTP access is anonymous.
However, if you give a file name which starts with "/~/" then Elvis will
attempt to login to the FTP server using you own account, as described in the
elvis.ftp or ~/.netrc configuration file.
You can also use "/~username/" to use some other user account listed in
.netrc
.
For example, "ftp://localhost/directory/file" uses anonymous FTP, but
"ftp://localhost/~/directory/file" uses your own account.
Elvis can write via FTP as well as read; see the Internet chapter.
Elvis also doesn't support inline graphic images, but that isn't as big
of a problem as you might think.
If you download an image, Elvis will simply load it into a buffer and then
display that buffer in the "hex" display mode.
You can then write that buffer's contents to a file, or in Unix you can send it
directly to an image viewer via a command such as ":w !xv -
".
The easiest way to save an image (or any other buffer) to a local file
is via the command ":w (dirfile(filename))
".
In fact, you might want to add the following lines to your ~/.exrc file
to make the (F2) key save the current buffer to a file,
and the (F3) key send it to the xv
image viewer:
map #2 :w (dirfile(filename))^M map #3 :w !xv -^M
To make images easier to fetch, any <IMG SRC=url> tag which isn't already part of a hypertext link will be interpreted as a link to the SRC url. This allows you to download an image by moving the cursor onto it and hitting the (Enter) key.
Elvis doesn't support frames either, so a similar trick was used for <FRAME SRC=url> tags. Elvis displays the name of each frame; those names serve as links to the contents of the frame.
Because Elvis is primarily an editor, not a Web browser, I deliberately made the "html" display mode rather picky, so that any questionable entities in your own HTML documents will call attention to themselves. When you're using Elvis to browse other peoples' documents, though, this can be annoying, so I modified it slightly to be more forgiving when you're viewing read-only documents. (All Web pages are read-only.)
And you already know that Elvis' support for the <TABLE> macros is very poor, right? If you encounter a Web page which looks really ugly in Elvis, you can bet it uses tables.
Elvis doesn't support forms, or secure connections. Well, Elvis can display mock-ups of forms; they just don't work. They probably never will. You have to draw the line somewhere.
Elvis doesn't always choose the best display mode for HTML pages. It uses "html" if the file name ends with ".html" or ".htm", or if the document's text begins with "<!", "<H", or "<h". For all other documents, it uses the "normal" or "hex" display mode by default. If Elvis chooses the wrong display mode, you can use the :display command to switch to a different display mode.
The command ":e foo
" will always load the local file "foo" from
your current directory.
This is true of all commands which normally act on files -- unless you
give a complete URL, Elvis assumes it should work with local files.
However, while in the "html" display mode, the command ":ta foo
"
will use the same protocol, site, and directory as the page you're already
viewing, because that's how the "html" display mode interprets tags.
(Aliases are a separate issue, discussed later in this chapter. The information in this section does not apply to aliases. Elvis does not yet offer any special tools for debugging aliases.)
Elvis has several features that make debugging macros much easier. For example, you can create a window which continuously displays the contents of a given cut buffer, such as "m, via the command:
:(Elvis cut buffer m)splitor, more concisely:
:("m)sp
Note: The cut buffer must exist before you can display it. Cut buffers are created the first time anything is yanked into them.
The maptrace option allows you to trace the execution of macros. You can either allow it to run through the macro, or wait for a keypress before each mapped command character. You can also use the :break and :unbreak commands to set or clear a breakpoint on a given :map macro. Breakpoints cause the maptrace option to switch from "run" to "step" when that macro is expanded.
The maplog option can be used to log the trace information to a buffer named "Elvis map log". The idea here is that you will give the command...
:se mt=r mlog=r... (or its full-length form,
:set maptrace=run maplog=reset
)
before starting the macro, and then when the macro fails you can
give the command...
:("Eml)sp... (or its full-length form,
:(Elvis map log)split
)
to see what it was doing shortly before the failure.
Note that the maplog option has no effect if maptrace is "off".
Warning: Elvis has a single keystroke queue which is shared by all windows. Because of this, while Elvis is running a macro in one window you can't switch to another window and type in commands. Even if the GUI allows you to switch windows without using the keyboard, doing so will simply force the macro to continue execution in the new window. So don't switch windows while a macro is running!
Here's a debugging methodology that works for me:
:se mt=r mlog=r
", and run the macro.
:("Eml)sp
"
to find out what commands executed immediately before the failure.
In particular look for a :map macro that was expanded shortly before
the failure.
:bre
macrokey".
:se mlog=o
".
If your macro reveals a bug in Elvis, please let me know! My email address is kirkenda@cs.pdx.edu. Please tell me which version of Elvis you're using, as reported by the :version command.
Usually, you will invoke your compiler or "make" utility via the
:cc or :make
commands.
The only difference between these commands is that :cc
invokes
the program named by the ccprg option,
and :make
uses the makeprg option.
Both of those options' values are evaluated using the simpler expression syntax, with $1 set to any extra command-line parameters, and $2 set to the current file name.
You can also read error messages from some other program with the command ":errlist !program", or read them from a file with the command ":errlist filename".
I often invoke Elvis via the command "elvis +make
" so
Elvis will attempt to compile the program, and move the cursor to the
first error (if there are any errors).
All of the compiler's output text is collected into a buffer named "Elvis error list". If you wish, you can view this list in a separate window via this command:
:(Elvis error list)split
Here's how Elvis parses each line of compiler output: Starting from the left, it divides the line into "words", which are defined as a series of letters, digits, and/or certain punctuation characters.
If the word is the name of an existing directory, then Elvis remembers that directory name. In later lines, Elvis will allow file names to be given relative to that directory, in addition to the current directory. This particular feature is intended to work with the directory lines generated by the GNU version of the "make" program.
If the word looks like a number, and no line number has been seen yet, then the word is taken to be a line number. If the word is the name of an existing, writable file (or any existing file if the anyerror option is set) in either the current directory or the directory remembered from a previous line as described above, then the word is taken to be a file name. Other words are ignored.
When Elvis has found both a file name and a line number, then it skips over any whitespace or punctuation immediately following them, and uses the remainder of the line as the error's description.
If Elvis fails to find a file name/line number pair, then it skips that whole line of compiler output.
Immediately after collecting compiler output, Elvis moves the cursor to the source of the first error. After that, you can use :errlist (with no arguments) or the visual * command to step through each following error.
Each time Elvis collects a new set of error messages, it remembers how many lines are in each buffer. Later, when you insert or delete lines to correct an error, Elvis can compare the current number of lines to original number of lines, and adjust the reported line numbers accordingly.
Here's something that may be useful for PERL programmers. PERL's error messages follow two distinct formats:
description in file file at line lineNeither of these looks like any recognizable compiler error message format; consequently, Elvis can't parse PERL's error messages directly. But here's a way around that. The following PERL program is a filter that reformats PERL's error messages to look like normal compiler error messages.
description at file line line
#!/usr/bin/perl $\ = "\n"; while (<>) { chop; s/(.*) in file ([^ ]*) at line (\d*).*/$2($3): $1/; s/(.*) at ([^ ]*) line (\d*)\.$/$2($3): $1/; print; }
To use this script, store it in a file named "perlerr" and turn on the file's "execute" permissions, and then set Elvis' ccprg option as follows:
For CSH: | :set ccprg="perl -c ($1?$1:$2) |& perlerr" |
Other shells: | :set ccprg="perl -c ($1?$1:$2) 2>&1 | perlerr" |
NOTE: You can't simply cut&paste the above Perl script into a file, because it contains some HTML code which Perl wouldn't understand. (The diamond is written as "<>".) A better way is to visually select those lines via the shift-V command, and then use the :wascii alias to save the formatted text to a file as plain ASCII text. You'll still need to edit the text file to remove leading whitespace and possibly some blank lines, but that's pretty easy.
Elvis locates the elvis.msg
file during initialization.
Ordinarily it searches through each directory named in the ELVISPATH
environment variable.
However, if there is an environment variable named LC_ALL, LC_MESSAGES,
or LANG (listed in order or precedence) which is set to a non-null value,
then Elvis will look for elvis.msg
first in a subdirectory whose
name matches the environment variable's value.
For example, if LC_ALL is unset, LC_MESSAGES=german, and
ELVISPATH=~/.elvis:/usr/local/lib/elvis, then Elvis would try to load
its messages from...
The digraph table tells Elvis which pairs of ASCII characters can be combined to form a single non-ASCII character. This table is configured via the :digraph command. To enter a digraph, type <Ctrl-K> and then the two ASCII characters. Elvis will store the corresponding non-ASCII character instead of the two ASCII characters. See the Input Mode chapter for more information.
The digraph table affects more than just keyboard input. It also affects "html" mode, and character type classifications.
Digraphs are used by the "html" display mode to translate character entities into characters. For example, when Elvis encounters ñ in an HTML document, it tries to find a digraph which combines 'n' with '~'. If there is such a digraph, Elvis will use it to display an 'ñ'; if not, then Elvis will display a plain 'n' character.
The digraph table affects the character classes, too. This, in turn, affects the definition of a "word", as used by the visual w command, among others. A non-ascii character is treated as an uppercase letter if, according to the digraph table, it is the result of combining an ASCII uppercase letter with either a punctuation character or a second uppercase letter. A similar rule holds for lowercase letters.
Also, Elvis tries to find uppercase/lowercase pairs through the digraph
table.
This is used for case conversions, as performed by the visual ~ command, or the \U
metacharacter in the :s/old/new command.
There is no way to specify a sorting order.
This means, in particular, that the
regular expression
/[a-z]/
will only match the ASCII lowercase letters,
not the non-ASCII ones. However, the regular expression
/[[:lower:]]/
will match all lowercase letters
including the non-ASCII ones.
The default elvis.ini file tries to load digraphs by executing either elvis.pc8 for MS-DOS, OS/2, or text-mode Win32, or elvis.lat for any other operating system.
The "win32" version of the "termcap" user interface has a codepage option which determines which symbol set is used for console output. If you change codepage, you should also adjust your digraph table.
The syntax of Elvis' :alias command
is intended to resemble that of the csh
Unix shell. The simplest
example of an alias is...
:alias save w... which would allow you to write your file out by running ":save", as an alternative to the standard ":w". If you pass any arguments to ":save" then they'll be appended to the ":w" command. For example, ":save foo" would be interpreted as ":w foo".
Here's another example. On Unix systems, this will make ":ls" display a directory listing.
:alias ls !!ls -C
Note that the above example requires two exclamation marks. This is because the "!" character is special in aliases -- Elvis' aliases allow you to use special symbols to indicate where arguments belong in the command text, and all of those symbols begin with a "!" character. When you invoke the alias, all of the symbols are replaced by argument values before the command text is executed. Here is a complete list of the replacement symbols:
.--------.-------------------------------------------------. | SYMBOL | REPLACED BY | |--------|-------------------------------------------------| | !< | first address line, if any addresses given | | !> | last address line, if any addresses given | | !% | address range, if any addresses given | | !? | "!" if the alias is invoked with a "!" suffix | | !* | the entire argument string except for "!" suffix| | !^ | the first word from the argument string | | !$ | the last word from the argument string | | !$* | all but the last word from the argument string | | !n | the nth word (where n is a single digit) | | !n* | everything from the nth word to the end | | !! | a single, literal "!" character | | !name= | value from a name=value argument | | !name& | URL-encoded version of !name= | ^--------^-------------------------------------------------^
Using any of the !*, !^, !$, !name=, !name&, or !1 through !9 symbols in the command string has the side-effect of disabling the normal behavior of appending the arguments to the command. Or to phrase that another way: If the command text doesn't explicitly say what to do with arguments, then Elvis will assume it should simply append them.
The other symbols, such as !% and !?, have no such default behavior. If your macro is going to use addresses or a "!" suffix, then you must explicitly include !% or !? (respectively) in the command string.
Here's a simple alias for playing around with these:
:alias show echo !!<=!< !!%=!% !!?=!? !!*=!* !!^=!^ !!2=!2 !!$=!$
The !name= and !name& symbols are intended mostly for use in user defined protocols, where they offer an easy way to examine the values of URL form fields. In any other type of alias, they search through the alias's arguments for one of the form name=value, and return the value portion of that arguments. Note that "!=" (without a name) is not substituted, so you don't need to do anything special to use the != operator in expressions within aliases.
Here's a more sophisticated version of the ":save" alias. This version allows you to use ":save!" as an alias for ":w!".
:alias save w!?
Here's a macro that converts a range of lines to uppercase. If invoked without any addresses, it will change only the current line, because that's the default for the :s command.
:alias upper !%s/.*/\U&/
You can define multi-line aliases by enclosing the lines in curly braces. The following example uses this technique to make a slightly smarter version of the "save" alias:
:alias save { "Write a file, but only if it has been modified if modified then w!? !* }
Note that the first line of the alias's body is a comment. (Comments start with a " character.) This is a good idea because when the :alias command is invoked with no arguments, it lists the names and first lines of all aliases. Putting a descriptive comment in the first line allows you to see what each alias does simply by examining that list.
If a multi-line alias is going to use arguments, then it must include !*, !^, !$, or !n symbols. Elvis does not, by default, append arguments to the end of a multi-line alias; it only does that for single-line aliases.
An alias can have the same name as a built-in command, but aliases can't be recursive. Together, these two rules mean that you can use an alias to change the behavior of a built-in command. For example, the following alias makes the :w command perform an RCS checkout operation if you don't already have write permission for a file. The "w" command inside the command text refers to the normal :write command since it isn't allowed to be a recursive call to the "w" alias.
:alias w { "Write a file, checking it out first if necessary if readonly && "!%!?!*" == "" then !!co -l % then w!! else !%w!? !* }You can optionally insert a ':' character between the '!' and the second character of any of these symbols. This has no effect; it is allowed simply to remain a little closer to CSH's alias syntax.
You can also optionally insert a '\' character between the '!' and the
second character.
This does have an effect:
It causes a backslash to be inserted before any characters which would
otherwise receive special treatment if they appeared in a regular expression.
Specifically, it will always insert a backslash before '\', '/', '^', '$',
'.', '[', or '*'.
Note that this is not sensitive to the
magic or
magicchar options;
in effect, it assumes that magic
and magicchar
are set to their default values.
Also, it never inserts a backslash before a '?' character even if it is used
in a regular expression which is delimited by '?' characters.
The following "find" alias will search for literal text:
:alias find /!\*In addition, you can optionally specify a default value for an argument, by placing the value in parentheses between the '!' and the second character. Here's an example which acts like echo, except that if you don't tell it what to echo then it will echo "Howdy!":
:alias greet echo !(Howdy!)*If necessary, you can insert both a backslash and a parenthesized default value. The backslash quoting will be applied to the given argument value, but not the parenthesized default value. Here's a variation of the "find" alias which searches for literal text, or if you don't specify any text to find then it searches for a { character at the front of a line.
:alias find /!(^{)\*Some vi commands are implemented via ex commands. If you create an alias with the same name as a built-in ex command, then the corresponding visual command will be affected. For example, the ZZ visual command runs :x, so the following alias would break the
ZZ
command...
:alias x echo Winners never quit, and quitters never win
lib/elvis.ali
.
I suggest you look at them.
The simple ones should give you some ideas of how to structure your own aliases,
and the complex examples will give you a feel of what can be accomplished.
Remember that the names of aliases must be spelled out in full;
you can't abbreviate alias names the way can for built-ins.
Also, you can display the definition of any alias by running
":alias
aliasname".
These examples are intended to be useful as well as instructive. They are loaded automatically when Elvis starts. The aliases in that file include:
[
directory]
[
!]
word [
word2]
:howto!
(with a ! suffix).
[
section]
topic
[
filename]
[
range]
ww[
!]
[
filename]
:ww
alias will attempt to perform an RCS "checkout"
operation on that file by running "!co -l
filename".
[
size]
["
bold"]
[
size]
["
bold"]
[
size]
:!
program &
" Elvis would wait
for the program to exit, so it could display the program's output in the
Elvis window.
:customize elvis.syn
"
to edit the syntax coloring rules.
[
range]
left
[
range]
right
[
range]
center
[
range]
wascii[
!]
file
[
range]
lpd[
!]
file
[
range]
cfmt
[
label]
optionname
*.c
or *.h
files in the
current directory for the given words, and treat the found
locations as a series of matching tags.
The :text
alias moves the cursor to the first location; you
can use an argumentless :tag command to move'
the each successive location.
The :btext
alias browses the matches, similar to the
:browse command.
[
name]
[
name]
Themes are basically the same as :load scripts. They just reside in a different subdirectory, and are intended to configure colors instead of aliases and options.
You should give this command in an empty edit buffer, with Elvis configured the way you want it to look, and any background images located in the current directory. After you run this alias, the edit buffer will be filled with an ex script and the images. You'll want to edit it to add a description, add your name to it, and maybe tweak the settings. Then save it to a file, and send file to me at kirkenda@cs.pdx.edu.
The theme should set the foreground & background for "normal", "idle", and the widgets and cursor. It may also set the background only of highlight faces such as "selection", "hlsearch", and "spell". Other faces, such as "comment", should not be set in the theme; instead, users are responsible for setting up their own favorite colors using the :color command's "or colorname" clauses to supply a variety of colors to choose from.
:e theme:/
" to see a web page of downloadable themes.
Most Elvis versions also allow you to add support for new protocols by defining aliases that handle reading and writing via that protocol. (Expressions can use the feature("proto") function to test for this feature.) The aliases must have the names "readXXX" and "writeXXX", where "XXX" is the uppercase name of the protocol.
The following example supports the "mailto:" protocol, on Unix/Linux systems:
alias readMAILTO { "initialize a mailto: message se noro reol=text if exists($HOME/".signature") read ~/.signature 1 i -- } } alias writeMAILTO { "send a mailto: message w !!mail -s"!(no subject)subject=" !2 >/dev/null 2>&1 se nomod }
After loading these aliases, the command
":e mailto:user@system.com
" will create an empty buffer named
"mailto:user@system.com", and then run the readMAILTO
alias
with the cursor located in that buffer.
The first thing that readMAILTO
does is turn off the
readonly option, and set the
readeol option to "text".
Elvis normally sets these to readonly
and reol=binary
because that's safest when downloading files via FTP or HTTP.
Since the whole point of the "mailto:" protocol is to write text, though,
those settings are inappropriate, so readMAILTO
changes them.
Other than that, readMAILTO
merely needs to insert a copy
of the ~/.signature file, if one exists.
You can then edit the message however you like, interactively.
When you want to send the message,
give the :w command.
Because the buffer's name
(actually the filename option)
starts with "mailto:", Elvis knows it should use the writeMAILTO
alias to write it.
The writeMAILTO
alias pipes the message out to the
standard Unix "mail" program.
This is a little trickier than it should be, because "mail" can fork off
a spooler process which can run for several minutes.
This could make Elvis' x11 user interface hang,
because it waits for stdout/stderr to close before resuming its normal activity,
and the spooler process inherits the stdout/stderr from the mail process.
The solution is to redirect the mail process' stdout/stderr to
/dev/null
.
After that, it turns off the buffer's modified option, so that other commands will know it is safe to delete that buffer.
Both the read
XXX and write
XXX
aliases are invoked with arguments derived from the URL.
The arguments contain pieces of the URL, as follows:
.--------.-------------------------------------------------------. | SYMBOL | REPLACEMENT TEXT | |--------|-------------------------------------------------------| | !* | Whole URL - protocol://sitename/resource#anchor?args | | !1 | Site name, if the URL contained one. | | !2 | Resource name | | !3 | The anchor name, if the URL contained one. | | !4 - !9| Form fields, if any (name=value, URL-decoded) | | !name= | Value of the form field named name, URL-decoded | | !name& | Value of the form field named name, URL-encoded | ^--------^-------------------------------------------------------^ Example: !term& .------. http://www.techweb.com/encyclopedia/defineterm.yb?term=firewall ^------!1-----^^----------!2-------------^ ^-----!4----^
In the "mailto:" example above, writeMAILTO
used !2 as the
email address of the person being mailed to.
It also used the subject field value, if one was supplied, but instead of
trying to locate it by searching through !4 - !9, it searched by name
using the !
name=
notation.
Specifically, it used "!(no subject)subject=
" to find the
value of the subject
field, or use "no subject" by default.
The difference between the !
name=
and
!
name&
notations is that
!
name&
is replaced with
URL-encoding intact, while
!
name=
is replaced with the
plain-text form of the parameter.
So !
name&
works better for
plugging a parameter into a newly constructed URL, while
!
name=
works better for most other
purposes.
The userprotocol option is turned
on for buffers loaded via a readPROTOCOL
alias.
The default elvis.arf
script is sensitive to this; it skips
certain setup steps, since the default setup steps might not be appropriate
for a user-defined protocol.
If you don't like this behavior,
then simply add a "set nouserprotocol
" command
to your readPROTOCOL
alias.
:calc feature("spell")
If it says True
then you're all set.
You should be able to enable spell-checking via the command:
:set spell
After that, any suspected misspellings will be highlighted. You can change the highlighting style via ":color spell ..."
Elvis is intended primarily for editing the source code of programs. In source code, some words should be checked only against the "tags" dictionary (function names and data types), some should be checked against both dictionaries (comments, mostly), and some should be unchecked (variables, since they often are not listed in the "tags" file). Elvis' spell checker can do that!
The spell-checking rules are oriented around faces. Faces are also used to control the font & color attributes of text, as configured via the :color command. Each face has a name, such as "comment" or "function". The spell checker doesn't care about the appearance of a face, but it cares a great deal about its name.
For each face, Elvis allows you to specify one of three levels of spell-checking:
.------.-----------------------------------------. | FLAG | TYPE OF SPELL-CHECKING PERFORMED | |------|-----------------------------------------| | * | Check against both dictionaries | | + | Check against only the tags dictionary | | - | Don't perform any spell checking | ^------^-----------------------------------------^
By default, most faces check against both dictionaries. The elvis.spe initialization file configures some faces to check against only the tags dictionary, or skip checking entirely.
If the defaults don't meet your needs, you can use the :check command to change the rules for any face. For example, the "variable" face isn't normally subjected to any type of spell checking. It would be nice if this could be checked against the tags dictionary, but most tags generators don't generate tags for all variables, so many valid variable names would be marked as misspelled. However, if you have a tags generator that does a thorough job on variables then you might want to enable spell-checking of variables against the tags dictionary. You probably wouldn't want to check variable names against the natural-language dictionary, though. The following command configures variable checking this way:
:check variable
Similarly, the "string" face isn't normally checked because strings tend to contain non-human text such as "\n" or "%d". If you want to enable checking against both dictionaries, you can use the following command:
:check *string
The "*" causes Elvis to use both dictionaries. In the earlier "variable" example, we could also have used a "+" flag to select just the tags dictionary, but that's the default so we omitted it. The "-" flag disables spell-checking:
:check -variable string
By the way, the :check command supports name completion, so you can use the <Tab> key to see what faces are available.
When loading tags, Elvis searches through all of the file names in the tags and elvispath options. If any of those names is a directory, then Elvis looks for a file named "tags" in that directory.
Elvis loads every tag from every file that it finds this way. All of these tag names are combined in RAM to form a single tags directory. Other tag information is ignored; Elvis only stores the names.
As long as you generate tags files in the usual way, Elvis should be able to find them without any trouble.
To make it even easier, if the "tags" file in the current directory is altered then Elvis will reload the tags dictionary automatically. (It doesn't check the "tags" files in other directories, though.)
All words in the tags dictionary are considered to be case-sensitive.
The way Elvis uses this dictionary is a bit tricky. The first thing you must realize is that the dictionary is maintained in RAM. It can pull words from the spelldict file as needed, but that file isn't the dictionary -- the in-memory data structure is.
The next big quirk is that the dictionary contains both correct and misspelled words. Elvis must remember misspelled words so that it can recognize them again quickly, without having to look them up in the spelldict file every time. This is very important because Elvis spell-checks every word on the screen, after every keystroke. Elvis can check any word against its in-memory dictionary in a fraction of a microsecond, but file searches are far slower.
You can use the :words command to add words to the natural-language dictionary. If you precede the words with a "-" then they'll be flagged as being incorrect. Any time Elvis displays that word on the screen, it'll be shown highlighted as an error. Words added without a "-" flag will be added as correct words.
If Elvis looks for a word in its dictionary, and doesn't find it, then it will try to find the word in the spelldict file. If Elvis finds it, great! Elvis will add it to its dictionary as a correct word. Otherwise, Elvis will will try suffix substitution, as specified via the spellsuffix option, and check the resulting word against the spelldict file again. If Elvis finds that word, then it will add both the found word and the original word, both flagged as correct words. Otherwise, Elvis will add the original word, flagged as incorrect.
Words pulled from the spelldict file are always considered to be case-insensitive, even if they're capitalized in that file. Words added via :wordfile are also case-insensitive. However, words added via the :words command are considered to be case-insensitive only when they're given in lowercase; if the a word contains any uppercase letters then it will be case-sensitive.
Words added via :word or
:wordfile are flagged as being personal,
unless you append a "!" suffix to the command name.
The distinction between personal words and other natural-language words
is important, because :mkexrc will store any
personal words in your .exrc
file.
ispell
.
However, Elvis does have an spell
option for highlighting misspelled words, and the
show option supports a "spell" keyword
which displays suggested corrections at the bottom of the screen.
It also has a gs command for
moving to the next misspelled word.
If the cursor is already on a misspelled word before gs,
and the show
option is presenting a list of suggestions,
then you can invoke gs with a "count" argument to fix the current
word before moving to the next word.
If none of the suggested alternative spellings are correct, you can use
c
gS (with an uppercase "S")
to replace the word manually.
Elvis' built in calculator has functions named spell() and spelltag(), which offer a way to access the spelling suggestions in your own aliases or scripts.
The spell()
function only checks the in-memory dictionary;
it doesn't scan the spelldict file.
Because of this, you'll probably want to load all words from that file into
memory.
There are two ways to do that:
either invoke the :wordfile command
explicitly,
or set the spellautoload option
to have it be loaded automatically the first time you need it.
Elvis maintains a list of auto commands. Each auto command contains:
The whole auto command feature is omitted from the MS-DOS version of Elvis, for the sake of compactness. Under MS-DOS, Elvis will continue to depend on elvis.arf and the related files.
To select a group for editing
(and to create the group if it didn't exist before),
use the :augroup command.
Typically, you'll begin by using
":aug groupname" to select
a group to edit, then wipe out any existing auto commands in that group and
define new ones, and then use
":aug END
"
to mark the end of the group.
:aug buflist :au! :au BufNewFile,BufReadPost * morebuffers :au BufDelete * lessbuffers :aug END
Note that the :augroup command only affects the behavior of later :autocmd commands. Afterward, when events occur, they will trigger all appropriate auto commands regardless of the group name. I.e., groups are useful for editing the auto command list, but have no effect on its actions.
Well, actually there is one exception: The :doau command can optionally be told a specific group name to run. If you don't specify the group name, then it will trigger all appropriate events in all groups, just like a real (non-:doau) event.
Elvis' version of :aug has a minor
extension beyond vim's capabilities:
when invoked with !
suffix
(":aug!
groupname")
it marks that group as being a "system" group.
Elvis' standard configuration scripts may use this notation to mark its own
groups.
The significance of this is, "system" groups aren't saved by the
:mkexrc command --
they don't need to be stored in your custom initialization file since they're
created by a standard script.
Event names are case-insensitive, so "BufCreate" can be written as "bufcreate", or even "BuFcReAtE".
The :doau command only accepts
a single event name -- the one that it is supposed to simulate.
However, the :au command accepts a
comma-delimited list of event names (without any whitespace between them),
or *
to represent all events.
When deleting/replacing events, if an auto command has been created with multiple events and you only delete/replace some of them, then the remaining ones will still be in effect. In other words, Elvis will remove the given events from each auto command's set of matching events, and will only completely delete an auto command if the remaining set of events is empty. (When deleting/replacing, it only effects auto commands where at least one of the new patterns is identical to one of the existing patterns.)
Here's a list of built-in events, and what they mean in Elvis. Note that even "Not implemented" events can be triggered explicitly by :doau, so they aren't totally useless. You can also create new events with the :auevent command.
:au AliasEnter * local magicchar=^$.*[ nomagicperl
:au BgChanged light color x11.spell on pink :au BgChanged dark color x11.spell on red
Vim also sends this event after a buffer is renamed, but Elvis doesn't
normally.
If you want to make Elvis perform BufCreate
when a buffer is
renamed, then make the BufFilePost event run
":doau BufCreate
",
like this:
:au BufFilePost * doau BufCreate
You could use this event with BufCreate to maintain
a list of open buffers.
The data/scripts/xbuf.ex
file, distributed with Elvis, contains an example
of how this might be done in Elvis' x11
user interface.
Warning: Elvis can switch buffers extremely often. For example, if you're using the "x11" user interface with multiple windows and toolbars, then Elvis will make each window's buffer be the "current" buffer while it is evaluating the states of each toolbar button, after each keystroke.
BufLeave
event (with the old buffer) before switching, and a
BufEnter event (with the new buffer) afterward.
BufNewFile
is triggered only when there is no file to be read.
You can use this to create a skeleton version of a file.
BufUnload
and
BufDelete are effectively the same thing.
Generally, Elvis will trigger a DispMapLeave
event on the old mode before triggering the
DispMapEnter
event on the new mode.
Both of these events will be triggered before the newly received keystrokes
are subjected to maps.
'[
and
']
marks indicate the changed region.
The Edit event is triggered every time the buffer is changed.
If you want to trigger an event for only the first
change to a buffer, then you can use the OptSet event to
watch for changes to the modified option.
(However, OptSet
doesn't set the
'[
and ']
marks.)
'[
and
']
marks indicate the region to be written, and the
aufilename option indicates the name
of the file that it'll be written to.
If any auto command triggered by this event causes an error and the
eventerrors option is set,
then the text will not be written.
FileReadPost
is triggered by the :r
command, but not the :e command.
The auto command can use '[
and ']
marks to
determine which lines are new.
See also FileReadPre for before the text has been
inserted, and FilterReadPost for reading from a
filter program.
FileReadPre
is triggered by the :r
command, but not the :e command.
See also FileReadPost for after the text has been
inserted, and FilterReadPre for reading from a
filter program.
'[
and
']
marks indicate the region to be written, and the
aufilename option indicates the name
of the file that it'll be written to.
If any auto command triggered by this event causes an error and the
eventerrors option is set,
then the text will not be written.
'[
and ']
marks to
determine which lines are new.
See also FilterReadPre for before the text has been
inserted, and FileReadPost for reading from a file.
'[
and
']
marks indicate the region to be written, and the
aufilename option stores a copy of
the command that it is writing to.
If any auto command triggered by this event causes an error and the
eventerrors option is set,
then the text will not be written.
NOTE:
Options changed via the
:set,
:let, and
:local
commands always trigger this event for any changed options, but
some options are changed internally by Elvis as a normal consequence
of operation, and
those changes don't always trigger the OptChanged
event.
For example, the bufchars option
changes any time you insert or delete text, but this doesn't trigger
OptChanged.
:au OptSet novice set nomagic report=1 showmode
NOTE:
As with OptChanged,
Elvis changes some options internally, and
those changes don't always trigger an OptSet
event.
:au ScriptEnter * local magicchar=^$.*[ nomagicperl
Note that ScriptEnter
and ScriptLeave
are executed both for scripts that are explicitly run via the
:so command, and the configuration scripts
that are run automatically:
elvis.brf,
elvis.arf,
elvis.bwf, and
elvis.awf.
Syntax
event.
You could have Elvis simulate it via the OptChanged
event:
:au OptChanged bufdisplay doau Syntax
User
event can only be triggered explicitly via the
:doau command.
Warning: Elvis can switch windows extremely often. For example, if you're using the "x11" user interface with multiple windows and toolbars, then Elvis will make each window be the "current" window while it is evaluating the states of each toolbar's buttons, after each keystroke.
WinLeave
event (with the old window), then switch windows,
and then trigger a WinEnter event (with the new window).
See also BufLeave.
*
" matches any text, of any length.
For example, "*.html
" matches all the names that end with
".html".
?
" matches any single character.
[
chars]
" matches
any single character in the chars list.
[^
chars]
" matches
any single character not in the chars list.
The contents of []
wildcards is always interpreted in
a case-sensitive manner, even in operating systems such as Windows which
are normally case-insensitive with respect to filenames.
If you want a []
expression to be case-insensitive, then you
must explicitly give both the uppercase and lowercase versions of the
letter.
The chars list may be individual characters, or ranges of
characters with a '-' between them. For example, [_a-zA-Z]
matches an underscore or a letter.
Although the syntax for For example, my computer (AMD K6-200) can run 10
generations of the "life" macros in 41 seconds with the default configuration. If I invoke Elvis with a reduced block size
( The blksize option indicates the
current block size. This is a read-only option; once Elvis has started,
(and hence has already created the session file) it is too late to request
a different block size.
Generally, smaller blocks are better if your CPU is slow or you're only
editing small files. Larger blocks are better if your disk is slow (e.g., the
temporary file is stored on a remote disk, accessed via a network) or you're
editing large files.
The blkhit
and blkmiss options count the number
of cache hits and misses, so you can compute the efficiency of the cache
as follows:
You'll probably find that 98% or more of the block requests are being
satisfied from the cache. However, since each miss takes thousands of
times longer to complete than a hit, each fraction of a percent means a lot.
In addition to the blocks themselves, the cache contains a hash table
which allows Elvis to quickly determine whether a block is in the cache
or not. If you increase the size of the cache, then you'll probably want to
increase the size of the table as well. The table size is controlled by the
blkhash option. Ideally, it should
be set to a prime number somewhat larger than blkcache...
or simply the largest possible value, since hash table entries are small.
The default is 61, and the upper bound is 300.
The session option indicates where
the current session file is stored, and the
sessionpath option indicates which
directories Elvis looked through when deciding where to put the session file.
These are read-only options, since it is too late to choose a new location
for the session file after the session file is already created.
If you need to force Elvis to store its session files in a different
directory, you should set the The directory option tells Elvis
where to store other temporary files, such as those used for piping text
through external programs. You can change its value at any time. (Note:
the real vi also has a directory option, but only allows you to change it
during initialization.)
The optimize option attempts to
eliminate superfluous screen updates while a macro is executing.
It is normally on, but you may want to verify that.
Some animation macros force it off.
Elvis also has an animation option
which, if optimize is on, causes Elvis
to bypass some of the animation steps. The default value is 3. If animations
look choppy then try reducing it to 1. Or set it to 10 or so for faster
animation.
The exrefresh option controls whether
Elvis should refresh the screen after each line output by an ex command, or
wait until the command completes and then update the screen once.
It is normally off, so the screen is only updated once.
Interestingly, the syntax-coloring display mode seems to run about as fast
as the normal display mode. One possible exception would be if you're running
Elvis over a slow modem connection then the extra escape sequences required for
sending color information may slow down screen updates.
If you have long lines, then Elvis may run somewhat faster when the
wrap option is set. This is because Elvis
always formats entire lines, even if only part of the line is visible on
the screen, and the "nowrap" display style shows more long lines (one per row)
than the "wrap" display style.
The keytime option indicates how long
Elvis should wait after receiving an Esc character to distinguish between
the <Esc> key, and some other function key which begins with an Esc.
Longer times are more reliable, especially when you're running over a network.
But shorter times allow a quicker response to the <Esc> key.
The fancier ANSI drivers such as NANSI.SYS also help. They allow Elvis
to redraw the screen very quickly. The URLs section
of this chapter tells you where you can find NANSI.SYS on the Internet.
Installing Elvis also has a compile-time option, controlled by the
FEATURE_RAM
declaration in If you often use "-b 2048" or "-f ram", then you might consider setting up
a batch file which runs them. For example, you could create a
[]
wildcards is similar to the
syntax for the [] metacharacter in regular expressions,
the two are not the same.
For example, you cannot use [[:alpha:]]
to match
any locale-dependent letter in a filename wildcard, though you can in
regular expressions.
16.9 How to make Elvis run faster
This section describes some ways you can "tune" Elvis to run faster.
None of these suggestions require recompiling Elvis.
-b1024
on the command line) and an increased cache
(:set blkcache=200 blkhash=300
),
it can run 10 generations in just 24 seconds.
The blksize option
Elvis uses fixed-size blocks to store buffers. The block size is chosen
when the session file is created. The default is 2048 bytes (or 1024 bytes
for MS-DOS), but you can override that by invoking Elvis with a
-bblksize flag.
The size must be a power of two, between 512 and 8192.
The block cache
In the interest of speed, Elvis has its own cache of blocks from the session
file. The blkcache option tells Elvis
how many blocks to store in the cache. You can change this value at any time.
If Elvis requires more cached blocks for a given editing operation than the
blkcache allows, then Elvis ignores blkcache and loads the required blocks into
the expanded cache; you can't make blkcache too small.
The default blkcache is 20 (except for MS-DOS, where it is 10),
and the upper bound is 200 blocks.
In MS-DOS, setting blkcache too high can cause Elvis to crash.
:calc (bh*100/(bh+bm))"%"
Syncing
Elvis has a sync option which, if set,
causes Elvis to force all dirty blocks out to disk occasionally. This is
a very slow operation, so the sync option is normally turned off.
If Elvis seems to be running exceptionally slowly, then you might want to
verify that sync is off.
You can check it by giving the command ":set sync?
".
Temporary files
The session file, and any other temporary files, should be stored on a local
hard disk. Storing them on a network drive will slow Elvis down a lot.
SESSIONPATH
environment variable
to a list of acceptable directories. Elvis will use the first directory
from that list which exists and is writable.
Screen updates
Options which add information to the bottom row of the window, such as
ruler and
showmode, can slow down screen updates.
If speed is critical, you should turn those options off.
Input
The pollfrequency option indicates
how often Elvis checks for an abort request from the user. (Abort requests
are usually given by typing ^C or by clicking on a window while a macro or
other time-consuming command is running). Smaller numbers give a quicker
response to an abort request, but will cause the command itself to run slower.
MS-DOS-specific tips
The single biggest improvement you can make is to switch from the 16-bit
MS-DOS version to the 32-bit text-mode Win32 version. It only runs under Windows95
or WindowsNT, not MS-DOS, but you can make it run in full-screen mode which
feels like MS-DOS. And it is *much* faster, because I really had to mangle
the MS-DOS version of Elvis to make it fit in the lower 640k.
smartdrv.exe
can be a big help.
Storing temporary files on a RAM disk (in extended/expanded memory please!)
can also help.
config.h
, which allows Elvis to store its buffers
in EMS/XMS memory instead of a file. This makes Elvis run much
faster, but it has some disadvantages. If Elvis crashes, there will be no
way to recover the contents of the edit buffers. Also the Microsoft functions
for accessing EMS/XMS memory are very bulky, and also require a fairly large
buffer; so if you enable FEATURE_RAM, then you must disable most of the other
FEATURE_XXXX features in config.h
, and even then Elvis may run out
of memory occasionally. If you enable FEATURE_RAM, then to actually use that
feature, you must invoke Elvis with "-f ram" on the command line.
elvis.bat
file containing...
elvis.exe -b 2048 -f ram %1 %2 %3 %4 %5 %6 %7 %8 %9