PREV Display UP Commands NEXT Mapping

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.


Quit buffer except if modified.

:q! Quit buffer without checking. In Viper, these two commands are identical. Confirmation is required if exiting modified buffers that visit files.
:stop 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 variable require-final-newline to t. If you don't like this feature, use setq-default to set require-final-newline to 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>.
:wq Write the file and kill buffer.
:r <file> [<file> ...] Read file into a buffer, inserting its contents after the current line.
:xit Same as :wq.
Save all unsaved buffers, asking for confirmation.
Like W, but without asking for confirmation.
ZZ 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.
:pre Preserve the file -- autosave buffers.
:rec Recover file from autosave.
:f Print file name and lines.
:cd [<dir>] Set the working directory to <dir> (default home directory).
:pwd 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 buffer.
:q! Quit Vi without writing.
C-^ Edit the alternate (normally the previous) file.
:rew Obsolete
:args 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.
:b Switch to another buffer. If ex-cycle-other-window is t, switch in another window. Buffer completion is supported.
:B 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.

PREV Display UP Commands NEXT Mapping