This chapter describes Vi commands other than Ex commands implemented in VIP. Except for the last section which discusses insert mode, all the commands described in this chapter are to be used in vi mode.
Most Vi commands accept a numeric argument which can be supplied as a prefix to the commands. A numeric argument is also called a count. In many cases, if a count is given, the command is executed that many times. For instance, 5 d d deletes 5 lines while simple d d deletes a line. In this manual the metavariable n will denote a count.
The keys C-g and C-l are unique in that their associated functions are the same in any of emacs, vi and insert mode.
keyboard-quit
).
recenter
).
In Emacs many commands are bound to the key strokes that start with C-x, C-c and ESC. These commands can be accessed from vi mode as easily as from emacs mode.
In Emacs the text you edit is stored in a buffer. See GNU Emacs Manual, for details. There is always one selected buffer which is called the current buffer.
You can see the contents of buffers through windows created by Emacs. When you have multiple windows on the screen only one of them is selected. Each buffer has a unique name, and each window has a mode line which shows the name of the buffer associated with the window and other information about the status of the buffer. You can change the format of the mode line, but normally if you see `**' at the beginning of a mode line it means that the buffer is modified. If you write out the content of the buffer to a file, then the buffer will become not modified. Also if you see `%%' at the beginning of the mode line, it means that the file associated with the buffer is write protected.
We have the following commands related to windows and buffers.
vip-next-window
).
delete-other-windows
).
split-window-vertically
).
vip-switch-to-buffer
).
vip-switch-to-buffer-other-window
).
vip-kill-buffer
).
list-buffers
).
As buffer name completion is provided, you have only to type in initial substring of the buffer name which is sufficient to identify it among names of existing buffers. After that, if you hit TAB the rest of the buffer name will be supplied by the system, and you can confirm it by RET. The default buffer name to switch to will also be prompted, and you can select it by giving a simple RET. See GNU Emacs Manual for details of completion.
We have the following commands related to files. They are used to visit, save and insert files.
vip-find-file
).
vip-find-file-other-window
).
In Emacs, you can edit a file by visiting it. If you wish to visit a file in the current window, you can just type v. Emacs maintains the default directory which is specific to each buffer. Suppose, for instance, that the default directory of the current buffer is `/usr/masahiko/lisp/'. Then you will get the following prompt in the minibuffer.
visit file: /usr/masahiko/lisp/
If you wish to visit, say, `vip.el' in this directory, then you can just type `vip.el' followed by RET. If the file `vip.el' already exists in the directory, Emacs will visit that file, and if not, the file will be created. Emacs will use the file name (`vip.el', in this case) as the name of the buffer visiting the file. In order to make the buffer name unique, Emacs may append `<2>', `<3>' etc., to the buffer name. As the file name completion is provided here, you can sometime save typing. For instance, suppose there is only one file in the default directory whose name starts with `v', that is `vip.el'. Then if you just type v TAB then it will be completed to `vip.el'. Thus, in this case, you just have to type v v TAB RET to visit `/usr/masahiko/lisp/vip.el'. Continuing the example, let us now suppose that you wished to visit the file `/usr/masahiko/man/vip.texinfo'. Then to the same prompt which you get after you typed v, you can enter `/usr/masahiko/man/vip.texinfo' or `../man/vip.texinfo' followed by RET.
Use V instead of v, if you wish to visit a file in another window.
You can verify which file you are editing by typing g. (You can also type X B to get nformation on other buffers too.) If you type g you will get an information like below in the echo area:
"/usr/masahiko/man/vip.texinfo" line 921 of 1949
After you edited the buffer (`vip.texinfo', in our example) for a while, you may wish to save it in a file. If you wish to save it in the file associated with the buffer (`/usr/masahiko/man/vip.texinfo', in this case), you can just say X S. If you wish to save it in another file, you can type X W. You will then get a similar prompt as you get for v, to which you can enter the file name.
In this and next section we discuss commands for moving around in the buffer. These command do not change the content of the buffer. The following commands are useful for viewing the content of the current buffer.
vip-scroll
).
vip-scroll-back
).
vip-scroll-down
).
vip-scroll-up
).
vip-scroll-down-one
).
vip-scroll-up-one
).
You can repeat these commands by giving a count. Thus, 2 SPC has the same effect as SPC SPC.
The following commands reposition point in the window.
vip-line-to-top
).
vip-line-to-middle
).
vip-line-to-bottom
).
recenter
).
The following commands are used to mark positions in the buffer.
Emacs uses the mark ring to store marked positions. The commands m <, m > and m . not only set mark but also add it as the latest element of the mark ring (replacing the oldest one). By repeating the command `m ,' you can visit older and older marked positions. You will eventually be in a loop as the mark ring is a ring.
Commands for moving around in the current buffer are collected here. These commands are used as an `argument' for the delete, change and yank commands to be described in the next section.
vip-backward-char
).
vip-forward-char
).
vip-next-line
).
vip-next-line
).
vip-next-line-at-bol
).
vip-previous-line-at-bol
).
If a count is given to these commands, the commands will be repeated that many times.
vip-beginning-of-line
).
vip-bol-and-skip-white
).
vip-goto-eol
).
vip-goto-col
).
Except for the | command, these commands neglect a count.
vip-forward-word
).
vip-forward-Word
).
vip-backward-word
).
vip-forward-Word
).
vip-end-of-word
).
vip-end-of-Word
).
Here the meaning of the word `word' for the w, b and e commands is determined by the syntax table effective in the current buffer. Each major mode has its syntax mode, and therefore the meaning of a word also changes as the major mode changes. See GNU Emacs Manual for details of syntax table.
vip-window-top
).
vip-window-middle
).
vip-window-bottom
).
These commands can be used to go to the desired line visible on the screen.
vip-backward-sentence
).
vip-forward-sentence
).
vip-backward-paragraph
).
vip-forward-paragraph
).
A count repeats the effect for these commands.
vip-goto-line
).
vip-goto-mark
).
vip-goto-mark-and-skip-white
).
vip-paren-match
).
The command G mark point before move, so that you can return to the original point by ` `. The original point will also be stored in the mark ring.
The following commands are useful for moving points on the line. A count will repeat the effect.
vip-find-char-forward
).
vip-find-char-backward
).
vip-goto-char-forward
).
vip-goto-char-backward
).
vip-repeat-find
).
vip-repeat-find-opposite
).
Following commands are available for searching and replacing.
vip-re-search
has value
t
then regular expression search is done and the string
matching the regular expression string is found. If you give an
empty string as string then the search mode will change from vanilla
search to regular expression search and vice versa
(vip-search-forward
).
vip-search-backward
).
vip-search-next
).
vip-search-Next
).
isearch-forward
).
isearch-backward
).
vip-replace-string
).
vip-query-replace
).
vip-replace-char
).
The commands / and ? mark point before move, so that you can return to the original point by ` `.
In this section, commands for modifying the content of a buffer are described. These commands affect the region determined by a motion command which is given to the commands as their argument.
We classify motion commands into point commands and line commands. The point commands are as follows:
h, l, 0, ^, $, w, W, b, B, e, E, (, ), /, ?, `, f, F, t, T, %, ;, ,
The line commands are as follows:
j, k, +, -, H, M, L, {, }, G, '
If a point command is given as an argument to a modifying command, the region determined by the point command will be affected by the modifying command. On the other hand, if a line command is given as an argument to a modifying command, the region determined by the line command will be enlarged so that it will become the smallest region properly containing the region and consisting of whole lines (we call this process expanding the region), and then the enlarged region will be affected by the modifying command.
For example, d $ will delete the region between point and end of current line since $ is a point command that moves point to end of line. d G will delete the region between the beginning of current line and end of the buffer, since G is a line command. A count given to the command above will become the count for the associated motion command. Thus, 3 d w will delete three words.
It is also possible to save the deleted text into a register you specify. For example, you can say " t 3 d w to delete three words and save it to register t. The name of a register is a lower case letter between a and z. If you give an upper case letter as an argument to a delete command, then the deleted text will be appended to the content of the register having the corresponding lower case letter as its name. So, " T d w will delete a word and append it to register t. Other modifying commands also accept a register name as their argument, and we will not repeat similar explanations.
We have more delete commands as below.
vip-kill-line
).
vip-delete-char
).
vip-delete-backward-char
).
Yank commands yank a text of buffer into a (usually anonymous) register. Here the word `yank' is used in Vi's sense. Thus yank commands do not alter the content of the buffer, and useful only in combination with commands that put back the yanked text into the buffer.
For example, y $ will yank the text between point and the end of line into an anonymous register, while "c y $ will yank the same text into register c.
Use the following command to yank consecutive lines of text.
vip-yank-line
).
Deleted or yanked texts can be put back into the buffer by the command below.
vip-put-back
).
vip-Put-back
).
Thus, " c p will put back the content of the register c into the buffer. It is also possible to specify number register which is a numeral between 1 and 9. If the number register n is specified, n-th previously deleted/yanked text will be put back. It is an error to specify a number register for the delete/yank commands.
Most commonly used change command takes the following form.
For example, if point is at the beginning of a word `foo' and you wish to change it to `bar', you can type c w. Then, as w is a point command, you will get the prompt `foo =>' in the minibuffer, for which you can type b a r RET to complete the change command.
VIP records the previous modifying command, so that it is easy to repeat it. It is also very easy to undo changes made by modifying commands.
vip-undo
).
vip-repeat
).
Miscellaneous Vi commands are collected here.
save-buffers-kill-emacs
).
vip-command-argument
).
vip-join-lines
).
vip-command-argument
).
vip-command-argument
).
vip-command-argument
).
The following keys are reserved for future extensions, and currently
assigned to a function that just beeps (vip-nil
).
&, @, U, [, ], _, q, ~
VIP uses a special local keymap to interpret key strokes you enter in vi mode. The following keys are bound to nil in the keymap. Therefore, these keys are interpreted by the global keymap of Emacs. We give below a short description of the functions bound to these keys in the global keymap. See GNU Emacs Manual for details.
set-mark-command
).
indent-for-tab-command
).
newline-and-indent
).
kill-line
).
recenter
).
previous-line
).
quoted-insert
).
isearch-backward
).
isearch-forward
).
transpose-chars
).
scroll-up
).
kill-region
).
You can enter insert mode by one of the following commands. In addition to
these, you will enter insert mode if you give a change command with a line
command as the motion command. Insert commands are also modifying commands
and you can repeat them by the repeat command . (vip-repeat
).
vip-insert
).
vip-Insert
).
vip-append
).
vip-Append
).
vip-open-line
).
vip-Open-line
).
vip-open-line-at-point
).
Insert mode is almost like emacs mode. Only the following 4 keys behave differently from emacs mode.
vip-change-mode-to-vi
).
delete-backward-char
).
vip-delete-backward-word
).
vip-ESC
).
You can also bind C-h to help-command
if you like.
(See section Customizing Key Bindings, for details.) Binding C-h to
help-command
has the effect of making the meaning of C-h
uniform among emacs, vi and insert modes.
When you enter insert mode, VIP records point as the start point of insertion, and when you leave insert mode the region between point and start point is saved for later use by repeat command etc. Therefore, repeat command will not really repeat insertion if you move point by emacs commands while in insert mode.