📄 elvis.9
字号:
The (j)oin command concatenates all lines in the specified range
together to form one big line. If only a single line is specified, then
the following line is catenated onto it.
The ! command runs an external filter program, and feeds the specified
range of lines to it's stdin. The lines are then replaced by the output
of the filter. A typical example would be ':'a,'z!sort -n' to sort the
lines 'a,'z according to their numeric values.
The < and > commands shift the specified range of lines left or right,
normally by the width of 1 tab character. The 'shiftwidth' option
determines the shifting amount.
The (s)ubstitute command finds the regular expression in each line, and
replaces it with the replacement text. The 'p' option causes the
altered lines to be printed, and the 'g' option permits all instances of
the regular expression to be found & replaced. (Without 'g', only the
first occurrence is replaced.)
Undo
undo
The (u)ndo command restores the file to the state it was in before your
most recent command which changed text.
Configuration & Status
map[!] [key mapped_to]
unmap[!] key
set [options]
mkexrc
[line] mark x
visual
version
[line][,line] =
file
The (ma)p command allows you to configure elvis to recognize your
function keys, and treat them as though they transmitted some other
sequence of characters. Normally this mapping is done only when in the
visual command mode, but with the [!] present it will map keys under all
contexts. When this command is given with no arguments, it prints a
table showing all mappings currently in effect. When called with two
arguments, the first is the sequence that your function key really
sends, and the second is the sequence that you want elvis to treat it as
having sent.
The (unm)ap command removes key definitions that were made via the map
command.
The (se)t command allows you examine or set various options. With no
arguments, it displays the values of options that have been changed.
With the single argument 'all' it displays the values of all options,
regardless of whether they've been explicitly set or not. Otherwise,
the arguments are treated as options to be set.
The (mk)exrc command saves the current configuration to a file called
.exrc in the current directory.
The mar(k) command defines a named mark to refer to a specific place in
the file. This mark may be used later to specify lines for other
commands.
The (vi)sual command puts the editor into visual mode. Instead of
emulating ex, elvis will start emulating vi.
The (ve)rsion command tells you that what version of elvis this is.
The = command tells you what line you specified, or, if you specified a
range of lines, it will tell you both endpoints and the number of lines
included in the range.
The file command tells you the name of the file, whether it has been
modified, the number of lines in the file, and the current line number.
Multiple Files
args [files]
next[!] [files]
Next[!]
previous[!]
rewind[!]
When you invoke elvis from your shell's command line, any filenames that
you give to elvis as arguments are stored in the args list. The (ar)gs
command will display this list, or define a new one.
The (n)ext command switches from the current file to the next one in the
args list. You may specify a new args list here, too.
The (N)ext and (pre)vious commands (they're really aliases for the same
command) switch from the current file to the preceding file in the args
list.
The (rew)ind command switches from the current file to the first file in
the args list.
Switching Files
edit[!] [file]
tag[!] tagname
The (e)dit command allows to switch from the current file to some other
file. This has nothing to do with the args list, by the way.
The (ta)g command looks up a given tagname in a file called 'tags".
This tells it which file the tag is in, and how to find it in that file.
Elvis then switches to the tag's file and finds the tag.
Exiting
quit[!]
wq
xit
The (q)uit command exits from the editor without saving your file.
The (wq) and (x)it commands (really two names for the same command) both
write the file before exiting.
File I/O
[line] read file
[line][,line] write[!][[>>]file]
The (r)ead command gets text from another file and inserts it after the
specified line.
The (w)rite command writes the whole file, or just part of it, to some
other file. The !, if present, will permit the lines to be written even
if you've set the readonly option. If you precede the filename by >>
then the lies will be appended to the file.
Directory
cd [directory]
chdir [directory]
shell
The (cd) and (chd)ir commands (really two names for one command) switch
the current working directory.
The (sh)ell command starts an interactive shell.
Debugging
[line][,line] debug[!]
validate[!]
These commands are only available if you compile elvis with the -DDEBUG
flag.
The de(b)ug command lists stats for the blocks which contain the
specified range of lines. If the ! is present, then the contents of
those blocks is displayed, too.
The (va)lidate command checks certain variables for internal
consistency. Normally it does not output anything unless it detects a
problem. With the !, though, it will always produce *some* output.
Extensions
In addition to the standard commands, a variety of extra
features are present in elvis that are not present in vi. They are
described below.
.exrc
Elvis first runs a .exrc file (if there is one) from your $HOME
directory. After that, it runs a .exrc (if there is one) from the
current directory. The one in the current directory may override
settings made by the one in the $HOME directory.
:mkexrc
:mk
This EX command saves the current :set and :map configurations in the
'.exrc' file in your current directory.
:args
:ar
You can use the :args command to define a new args list, as in:
:args *.h
After you have defined a new args list, the next time you issue a
:next command elvis will switch to the first file of the new list.
:Next
:previous
:N
:pre
These commands move backwards through the args list.
zz
In VI, the (lowercase) 'zz' command will center the current line on
the screen, like 'z="
.
The default count value for . is the same as the previous command
which . is meant to repeat. However, you can supply a new count if
you wish. For example, after '3dw', '.' will delete 3 words, but '5.'
will delete 5 words.
"
The text which was most recently input (via a 'cw' command, or
something similar) is saved in a cut buffer called ". (which is a
pretty hard name to write in an English sentence). You can use this
with the 'p' or 'P' commands thusly:
".p
K
You can move the cursor onto a word and press shift-K to have elvis
run a reference program to look that word up. This command alone is
worth the price of admission! See the ctags and ref programs.
input
You can backspace back past the beginning of the line. If you type
CTRL-A, then the text that you input last time is inserted. You will
remain in input mode, so you can backspace over part of it, or add
more to it. (This is sort of like CTRL-@ on the real vi, except that
CTRL-A really works.)
Real vi can only remember up to 128 characters of input, but elvis
can remember any amount.
:set charattr
:se ca
Elvis can display 'backslash-f' style character attributes on the
screen as you edit. The following example shows the recognized
attributes:
normal boldface italics
NOTE: you must compile elvis without the -DSET_NOCHARATTR flag for
this to work.
Omissions
A few vi features are missing. The replace mode is a hack. It
does not save the text that it overwrites.
Long lines are displayed differently----where the real vi would
wrap a long line onto several rows of the screen, elvis simply displays
part of the line, and allows you to scroll the screen sideways to see
the rest of it.
The ':preserve' and ':recover' commands are missing, as is the -r
flag. ':Preserve" is practically never used and since use of
':recover\*(CQ is so rare, it was decided to implement it as a separate
program. There's no need to load the recovery code into memory every
time you edit a file.
LISP support is missing. The '@' and ':@' commands are missing.
You cannot APPEND to a cut buffer.
Options
A variety of options can be set as described below:
Name Abbr Type Default Description
autoindent as Bool FALSE autoindent during input?
autowrite aw Bool FALSE write file for :n command?
charattr ca Bool FALSE display bold & underline chars?
columns co Number 80 width of screen, in characters
directory dir String /usr/tmp where tmp files are kept
errorbells eb Bool TRUE ring bell on error?
exrefresh er Bool TRUE EX mode calls write() often?
ignorecase ic Bool FALSE searches: upper/lowercase OK?
keytime kt Number 1 allow slow receipt of ESC seq?
keywordprg kp String /usr/bin/ref program to run for shift-K
lines ln Number 25 height of screen, in lines
list li Bool FALSE show tabs as '^I'?
magic ma Bool TRUE searches: allow metacharacters?
paragraphs pa String PPppPApa paragraphs start with .PP, etc.
readonly ro Bool FALSE no file should be written back?
report re Number 5 report changes to X lines?
scroll sc Number 12 default #lines for ^U and ^D
sections se String SEseSHsh sections start with .SE, etc.
shell sh String /bin/sh shell program, from environment
shiftwidth sw Number 8 width of < or > commands
sidescroll ss Number 8 #chars to scroll sideways by
sync sy Bool FALSE call sync() after each change?
tabstop ts Number 8 width of a tab character
term te String "?" terminal type, from environment
vbell vb Bool TRUE use visible bell if possible?
warn wa Bool TRUE warn if file not saved for :!cmd
wrapmargin wm Number 0 Insert newline after which col?
wrapscan ws Bool TRUE searches: wrap at EOF?
autoindent
During input mode, the autoindent option will cause each added line
to begin with the same amount of leading whitespace as the line above
it. Without autoindent, added lines are initially empty.
autowrite
When you're editing one file and decide to switch to another----via
the :tag command, or :next command, perhaps----if your current file
has been modified, then elvis will normally print an error message
and refuse to switch.
However, if the autowrite option is on, then elvis will write the
modified version of the current file and successfully switch to the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -