Go to the first, previous, next, last section, table of contents.

Ex Commands

In vi mode, you can execute an Ex command ex-command by typing:

: ex-command RET

Every Ex command follows the following pattern:

address command ! parameters count flags

where all parts are optional. For the syntax of address, the reader is referred to the reference manual of Ex.

In the current version of VIP, searching by Ex commands is always magic. That is, search patterns are always treated as regular expressions. For example, a typical forward search would be invoked by :/pat/. If you wish to include `/' as part of pat you must preceded it by `\'. VIP strips off these \'s before / and the resulting pat becomes the actual search pattern. Emacs provides a different and richer class or regular expressions than Vi/Ex, and VIP uses Emacs' regular expressions. See GNU Emacs Manual for details of regular expressions.

Several Ex commands can be entered in a line by separating them by a pipe character `|'.

Ex Command Reference

In this section we briefly explain all the Ex commands supported by VIP. Most Ex commands expect address as their argument, and they use default addresses if they are not explicitly given. In the following, such default addresses will be shown in parentheses.

Most command names can and preferably be given in abbreviated forms. In the following, optional parts of command names will be enclosed in brackets. For example, `co[py]' will mean that copy command can be give as `co' or `cop' or `copy'.

If command is empty, point will move to the beginning of the line specified by the address. If address is also empty, point will move to the beginning of the current line.

Some commands accept flags which are one of p, l and #. If flags are given, the text affected by the commands will be displayed on a temporary window, and you will be asked to hit return to continue. In this way, you can see the text affected by the commands before the commands will be executed. If you hit C-g instead of RET then the commands will be aborted. Note that the meaning of flags is different in VIP from that in Vi/Ex.

(.,.) co[py] addr flags
(.,.) t addr flags
Place a copy of specified lines after addr. If addr is 0, it will be placed before the first line.
(.,.) d[elete] register count flags
Delete specified lines. Text will be saved in a named register if a lower case letter is given, and appended to a register if a capital letter is given.
e[dit] ! +addr file
e[x] ! +addr file
vi[sual] ! +addr file
Edit a new file file in the current window. The command will abort if current buffer is modified, which you can override by giving !. If +addr is given, addr becomes the current line.
file
Give information about the current file.
(1,$) g[lobal] ! /pat/ cmds
(1,$) v /pat/ cmds
Among specified lines first mark each line which matches the regular expression pat, and then execute cmds on each marked line. If ! is given, cmds will be executed on each line not matching pat. v is same as g!.
(.,.+1) j[oin] ! count flags
Join specified lines into a line. Without !, a space character will be inserted at each junction.
(.) k ch
(.) mar[k] ch
Mark specified line by a lower case character ch. Then the addressing form 'ch will refer to this line. No white space is required between k and ch. A white space is necessary between mark and ch, however.
map ch rhs
Define a macro for vi mode. After this command, the character ch will be expanded to rhs in vi mode.
(.,.) m[ove] addr
Move specified lines after addr.
(.) pu[t] register
Put back previously deleted or yanked text. If register is given, the text saved in the register will be put back; otherwise, last deleted or yanked text will be put back.
q[uit] !
Quit from Emacs. If modified buffers with associated files exist, you will be asked whether you wish to save each of them. At this point, you may choose not to quit, by hitting C-g. If ! is given, exit from Emacs without saving modified buffers.
(.) r[ead] file
Read in the content of the file file after the specified line.
(.) r[ead] ! command
Read in the output of the shell command command after the specified line.
se[t]
Set a variable's value. See section Customizing Constants, for the list of variables you can set.
sh[ell]
Run a subshell in a window.
(.,.) s[ubstitute] /pat/repl/ options count flags
(.,.) & options count flags
On each specified line, the first occurrence of string matching regular expression pat is replaced by replacement pattern repl. Option characters are g and c. If global option character g appears as part of options, all occurrences are substituted. If confirm option character c appears, you will be asked to give confirmation before each substitution. If /pat/repl/ is missing, the last substitution is repeated.
st[op]
Suspend Emacs.
ta[g] tag
Find first definition of tag. If no tag is given, previously given tag is used and next alternate definition is find. By default, the file `TAGS' in the current directory becomes the selected tags table. You can select another tags table by set command. See section Customizing Constants, for details.
und[o]
Undo the last change.
unm[ap] ch
The macro expansion associated with ch is removed.
ve[rsion]
Tell the version number of VIP.
(1,$) w[rite] ! file
Write out specified lines into file file. If no file is given, text will be written to the file associated to the current buffer. Unless ! is given, if file is different from the file associated to the current buffer and if the file file exists, the command will not be executed. Unlike Ex, file becomes the file associated to the current buffer.
(1,$) w[rite]>> file
Write out specified lines at the end of file file. file becomes the file associated to the current buffer.
(1,$) wq ! file
Same as write and then quit. If ! is given, same as write ! then quit.
(.,.) y[ank] register count
Save specified lines into register register. If no register is specified, text will be saved in an anonymous register.
addr ! command
Execute shell command command. The output will be shown in a new window. If addr is given, specified lines will be used as standard input to command.
($) =
Print the line number of the addressed line.
(.,.) > count flags
Shift specified lines to the right. The variable vip-shift-width (default value is 8) determines the amount of shift.
(.,.) < count flags
Shift specified lines to the left. The variable vip-shift-width (default value is 8) determines the amount of shift.
(.,.) ~ options count flags
Repeat the previous substitute command using previous search pattern as pat for matching.

The following Ex commands are available in Vi, but not implemented in VIP.

abbreviate, list, next, print, preserve, recover, rewind, source,
unabbreviate, xit, z

Go to the first, previous, next, last section, table of contents.