
Vim is a well-known text editor used by all UNIX systems. It is based on vi ("visual") and which is based on ex again. The main advantages of Vim are less system requirements, configurability and it's spread. The most important opponent of Vim is the GNU Emacs editor. Vim is free and OpenSource.

Vim does not require any graphical user interface and can be started throughout the Command Line Interface / a terminal. In general, you don't have to type Vim, because in general vi starts vim. You can set the filename as the second argument (maybe a new file?)
vi Vim_file
Use option -R to view a file in readonly-mode
vi -R Vim_file
Use the UNIX manual man vi to get any further information. Use vimtutor to get a built-in tutorial.
There are two modes: Insert- and Commandline-Mode. After starting vim, you are in Commandline-Mode. You can always get into Commandline-Mode by pressing Esc. In Commandline-Mode press i to switch into Insert-Mode. To write the text "Hello World!" in a new file, use the following commands:
vi new_file
i
Hello World
:wq
Why did I highlight the commands differently? Well... the first command is a bash command (your shell has to proceed it). The second command is a Vim-command and will be inserted to the Vim command line (at the bottom of the Vim screen). And the last command is an ex-command. Vim tells ex to proceed the command (w = write; q = quit). Ex-commands always start with a colon. Prepend it, if not specified!
| vi | Start vi |
| vi filename | Start vi and load file $filename |
| vi -R filename | ... in read-only Mode |
| i | Enter Insert-Mode |
| w | write file |
| q | quit Vim |
| q! | force quitting Vim (→ without saving changes) |
| ZZ | Save file and quit editor |
| i | Enter Insert-Mode |
| ls | :ls 1 %a "file1.html" line 1 2 "file2.html" line 13 show all opened files |
| e | Reload file |
| e! | Force reloading file (→ without saving changes) |
| h | left (one letter) |
| j | down (one line) |
| k | up (one line) |
| l | right (one letter) |
| 0 | (zero) jump to the beginning of the line |
| $ | jump to the end of the line |
| b | previous word |
| B | previous word (but don't consider punctuations and symbols) |
| w | next word |
| W | next word, but don't consider punctuations and symbols |
| + | jump to 0 of the next line |
| - | jump to 0 of the previous line |
| e | end; jump to the end of the current word |
| E | end; jump to the end of the current word (but don't consider punctuations and symbols) |
You can use the commands multiple times by prepending numbers. 5B will jump 5 words backwards.
| a | append; append text to the current cursor position |
| c | change; only useful in combination with movement command |
| d | delete; delete content (and copy it to the buffer) |
| p | put; insert content from the buffer |
| y | yank; copy content into the buffer |
You can use the commands multiple times by prepending numbers. 5B will jump 5 words backwards. c2b will change the two previous words.
| redo | redo |
| undo | undo |
| u | undo |
| U | undo all changes in current line unless you didn't move away |
| R | toggle to replacement mode (exit by pressing Esc) |
| ~ | change letter at current position to uppercase/lowercase |
| dd | delete the whole current line |
| P | put; insert content from the buffer BEFORE the cursor |
| xp | transpose two letters |
| J | merge two lines (append next line to current one) |
You can use the commands multiple times by prepending numbers. 5B will jump 5 words backwards. c2b will change the two previous words.
| A | append text to end of line |
| I | insert text at end of line |
| o | open line; create new empty line below current cursor position |
| O | Open line; create new empty line after current cursor position |
| s | substitute; replace a letter |
| S | Substitute; replace a line |
After executing those commands, you will be in insertion mode
(command)(text unit)
eg. cw
eg. dw
eg. yw
(command)(number)(text unit) ...equals to...
(number)(command)(text unit)
eg. c2b
eg. 2cb
| Object | copy | change | delete |
| 1 word | yw | cw | dw |
| 2 words without symbol consideration | 2yW / y2W | 2cW / c2W | 2dW / d2W |
| 3 word backwards | 3yb / y3b | 3cb / c3b | 3db / d3b |
| 1 line | yy / Y | cc | dd |
| until end of line | y$ | c$ / C | d$ / D |
| to beginning of line | y0 | c0 | d0 |
| single characters | y1 / yh | r | x / X |
| 5 characters | 5y1 | 5s | 5x |
| wm=10 | set wrapmargin to 10 |
| nu | show number of line |
official Vim homepage
Vim @ sourceforge
download from sourceforge
Vim Scripts
written by Lukas Prokop in July 2009
based on Textverarbeitung mit dem vi-Editor