1. Tech

Your suggestion is on its way!

An email with a link to:


was emailed to:

Thanks for sharing About.com with others!

Linux / Unix Command: vim, gvim
Command Library


% vim [options] [file ..]


vim is a text editor that is backwards compatible with vi. It can be used to edit any ASCII text and is especially useful for editing programs.

givm: The GUI version of vi is also available: type gvim in an X terminal.

Most often vim is started to edit a single file with the command:

% vim file

More generally it is started with:

% vim [options] [filelist]

If no filelist is specified, the editor starts with an empty buffer. Otherwise the first file in the list alphabetically) will be the current file and read into the buffer. The cursor will be positioned on the first line of the buffer. You can get to the other files with the ":next" command.


The options, if present, must precede the filelist. The options may be given in any order.

Recovery mode. The swap file is used to recover a crashed editing session. The swap file is a file with the same file name as the text file with ".swp" appended. See reference.doc, chapter "Recovery after a crash".

View mode. The 'readonly' option will be set. You can still edit the buffer, but will be prevented from accidently overwriting a file. If you do want to overwrite a file, add an exclamation mark to the Ex command, as in ":w!". The -v option also implies the -n option (see below). The 'readonly' option can be reset with ":set noro" (see reference.doc,
options chapter).

Binary. A few options will be set that makes it possible to edit a binary or executable file.

For the first file the cursor will be positioned on line "num". If "num" is missing, the cursor will be positioned on the last line.

For the first file the cursor will be positioned on the first occurrence of "pat" (see reference.doc, section "pattern searches" for the available search patterns).


-c {command}
{command} will be executed after the first file has been read. {command} is interpreted as an Ex command. If the {command} contains spaces it must be enclosed in double quotes (this depends on the shell that is used). EXAMPLE: Vim "+set si" main.c

Open N windows. When N is omitted, open one window for each file.

No swap file will be used. Recovery after a crash will be impossible. Handy if you want to edit a file on a very slow medium (e.g. floppy). Can also be done with ":set uc=0". Can be undone with ":set uc=200".

-s {scriptin}
The script file {scriptin} is read. The characters in the file are interpreted as if you had typed them. The same can be done with the command ":source! {scriptin}". If the end of the file is reached before the editor exits, further characters are read from the keyboard.

-w {scriptout}
All the characters that you type are recorded in the file {scriptout}, until you exit VIM. This is useful if you want to create a script file to be used with "vim -s" or ":source!".

-T terminal
Tells Vim the name of the terminal you are using. Should be a terminal known to Vim (builtin) or defined in the termcap file.


% vim parse_record.pl

Starts vim with the default settings and opens file parse_record.pl.

Important: Use the man command (% man) to see how a command is used on your particular computer.

>> Linux Command Library Index

>> Also see Shell Command Library

You can opt-out at any time. Please refer to our privacy policy for contact information.

Discuss in my forum

©2014 About.com. All rights reserved.