4.4 File and Buffer Handling
In all file handling commands, space should be typed before entering the file
name. If you need to type a modifier, such as >> or !, don't
put any space between the command and the modifier.
Note that many Ex commands, e.g., :w, accept command arguments. The
effect is that the command would start acting on the current region. For
instance, if the current region spans the lines 11 through 22, then if you
type 1:w you would see ‘:11,22w’ in the minibuffer.
- Quit buffer except if modified.
- Quit buffer without checking. In Viper, these two commands
are identical. Confirmation is required if exiting modified buffers that
- Suspend Viper
- :[x,y] w
- Write the file. Viper makes sure that a final newline is always added to
any file where this newline is missing. This is done by setting Emacs
t. If you don't like this
setq-default to set
nil. This must be done in .viper file.
- :[x,y] w <name>
- Write to the file <name>.
- :[x,y] w>> <name>
- Append the buffer to the file <name>. There should be no space between
w and >>. Type space after the >> and see what happens.
- :w! <name>
- Overwrite the file <name>. In Viper, :w and :w! are identical.
Confirmation is required for writing to an existing file (if this is not
the file the buffer is visiting) or to a read-only file.
- :x,y w <name>
- Write lines x through y to the file <name>.
- Write the file and kill buffer.
- :r <file> [<file> ...]
- Read file into a buffer, inserting its contents after the current line.
- Same as :wq.
- Save all unsaved buffers, asking for confirmation.
- Like W, but without asking for confirmation.
- Save current buffer and kill it. If user level is 1, then save all files
and kill Emacs. Killing Emacs is the wrong way to use it, so you should
switch to higher user levels as soon as possible.
- :x [<file>]
- Save and kill buffer.
- :x! [<file>]
- :w![<file>] and :q.
- Preserve the file—autosave buffers.
- Recover file from autosave.
- :f [<file>]
- without the argument, prints file name and character/line information afout
the currently visited file. With an argument, sets the currently visited
filename to file.
- :cd [<dir>]
- Set the working directory to <dir> (default home directory).
- Print present working directory.
- :e [+<cmd>] <files>
- Edit files. If no filename is given, edit the file visited by the current
buffer. If buffer was modified or the file changed on disk, ask for
confirmation. Unlike Vi, Viper allows :e to take multiple arguments.
The first file is edited the same way as in Vi. The rest are visited
in the usual Emacs way.
- :e! [+<cmd>] <files>
- Re-edit file. If no filename, re-edit current file.
In Viper, unlike Vi, e! is identical to :e. In both cases, the
user is asked to confirm if there is a danger of discarding changes to a
- Quit Vi without writing.
- Edit the alternate (normally the previous) file.
- List files not shown anywhere with counts for next
- :n [count] [+<cmd>] [<files>]
- Edit <count> file, or edit files. The count comes from :args.
- :N [count] [+<cmd>] [<files>]
- Like :n, but the meaning of the variable
ex-cycle-other-window is reversed.
- Switch to another buffer. If ex-cycle-other-window is
switch in another window. Buffer completion is supported.
The variable viper-read-buffer-function controls which function is
actually used to read the buffer name. The default is
but better alternatives are also available in Emacs (e.g.,
- Like :b, but the meaning of ex-cycle-other-window is reversed.
- :<address>r <name>
- Read the file <name> into the buffer after the line <address>.
- v, V, C-v
- Edit a file in current or another window, or in another frame. File name
is typed in minibuffer. File completion and history are supported.