Vim is a free and open-source, screen-based text editor program, It is a improved clone of Bill Joy's vi. Vim's author, Bram Mooleanaar.
Global
| comand | Description |
| :sav text.txt | save file as |
| :ter | open terminal |
| K or KK | open man page for word under the cursor |
| :h testing | open help for testing |
| :Ctrl+i | list arguments |
| :changes | list of changes |
| :wq or :x or ZZ | save and quit |
| :q! | quit unsave |
cursor movements
| Command | Description |
| h | Left |
| j | Down |
| k | Up |
| l | Right |
| H | move to top of screen |
| M | move to middle of screen |
| L | move to bottom of screen |
| w | jump to start next word |
| W | jump to start next word(with punctuation) |
| e | jump to end the word |
| E | jump to end the word(with punctuation) |
| b | jump backwards to start of the word |
| B | jump backwards to start f the word(with punctuation) |
| % | move to matching character |
| 0 | move to start the line |
| ^ | move to start the line (no blank character) |
| $ | move to end the line |
| gg | jump to top document |
| G | jump to end document |
| 5G or 5gg | jump to line 5 of document |
| gd | move to local declaration |
| gD | move to global declaration |
| fx | move to next character x in the line |
| Fx | move to previous character x in the line |
| Tx | move to after previous character of character x |
| ; | repeat previous f,t,F,T movement |
| , | repeat previous f,t,F,T movement, backwards |
| } | jump to next paragraph or function |
| { | jump to previous paragraph or function |
| zz | put cursor as center |
| zt | put cursor as top |
| zb | put cursor as buttom |
| Ctrl+e | move document without cursor up |
| Ctrl+y | move document without cursor down |
| Ctrl + o | move to last location |
Insert Mode
| Command | Description |
| i | insert before the cursor |
| I | insert at the start of line |
| a | insert after the cursor |
| A | insert at the end of line |
| o | insert a new line below |
| O | insert a new line above |
| Ctrl+h | move cursor before character |
| Ctrl+l | move cursor after character |
| Ctrl+e | move to end line |
| Ctrl+b | move to start line |
| Ctrl+w | delete the word before cursor |
| Ctrl+u | delete all content before cursor |
| Ctrl+j | jump to next line |
| Ctrl+k | jump to before line |
| Ctrl+t | indent line |
| Ctrl+d | indent line backward |
| Ctrl+n | insert next match autocomplete |
| Ctrl+p | insert the before match autocomplete |
| Ctrl+o+command | temporarily insert to mode normal |
| Ctrl+c | exit insert mode |
editing
| Command | Description |
| r | replace single character |
| R | replace more that one character |
| J | join two line with one space |
| gJ | join two line without space |
| gwip | reflow paragraph |
| g~ | switch case all line |
| gu | change to lowercase line |
| gU | change to uppercase line |
| cc or S | replace one line |
| C | replace all line after cursor |
| ciw | replace word |
| ce or cw | replace in word after the cursor |
| s | delete character and replace with text |
| xp | delete and paste one character |
| D or d$ | delete to end the line |
| u | undo |
| U | undo the last line changed |
| . | repeat last command |
Visual Mode
| Command | Description |
| v | start visual mode in cursor |
| V | start visual mode in line |
| o | move to other end on market area |
| Ctrl+v | start visual mode in block mode |
| O | move to other end on block mode |
| aw | mark word |
| ab | mark a block with () |
| aB | mark a block with {} |
| at | mark block with <> |
| ib | inner block with () |
| iB | inner block with {} |
| it | inner block with <> |
| > or < | indenting market area |
| y | copy marked area |
| d | delete market area |
| ~ | switch case market area |
| u | change marked area to lowercase |
| U | change market area to uppercase |
registers
| Command | Description |
| :reg | show register content |
| xy | copy the register with name x |
| xp | paste the register with name x |
| +y | copy to system clipboard |
| +p | paste from the system register |
Macros
| Command | Description |
| qa | record macro |
| q | stop macro |
| @a | run macro |
| @@ | re run macro |
Copy and Paste
| Comand | description |
| yy | yank (copy) a line |
| 2yy | yank (copy) 2 lines |
| yw | yank (copy) the characters of the word from the cursor position to the start of the next word |
| yiw | yank (copy) word under the cursor |
| yaw | yank (copy) word under the cursor and the space after or before it |
| y$ or Y | yank (copy) to end of line |
| p | put (paste) the clipboard after cursor |
| P | put (paste) before cursor |
| gp | put (paste) the clipboard after cursor and leave cursor after the new text |
| gP | put (paste) before cursor and leave cursor after the new text |
| dd | delete (cut) a line |
| 2dd | delete (cut) 2 lines |
| dw | delete (cut) the characters of the word from the cursor position to the start of the next word |
| diw | delete (cut) word under the cursor |
| daw | delete (cut) word under the cursor and the space after or before it |
| :3,5d | delete lines starting from 3 to 5 |
| ctrl+r | return the alt+u |
Tabs
Windows
| Command | Description |
| :e[dit] file | edit a file in a new buffer |
| :bn[ext] | go to the next buffer |
| :bp[revious] | go to the previous buffer |
| :bd[elete] | delete a buffer (close a file) |
| :b[uffer]# | go to a buffer by index # |
| :b[uffer] file | go to a buffer by file |
| :ls or :buffers | list all open buffers |
| :sp[lit] file | open a file in a new buffer and split window |
| :vs[plit] file | open a file in a new buffer and vertically split window |
| :vert[ical] ba[ll] | edit all buffers as vertical windows |
| :tab ba[ll] | edit all buffers as tabs |
| Ctrl + ws | split window |
| Ctrl + wv | split window vertically |
| Ctrl + ww | switch windows |
| Ctrl + wq | quit a window |
| Ctrl + wx | exchange current window with next one |
| Ctrl + w= | make all windows equal height & width |
| Ctrl + wh | move cursor to the left window (vertical split) |
| Ctrl + wl | move cursor to the right window (vertical split) |
| Ctrl + wj | move cursor to the window below (horizontal split) |
| Ctrl + wk | move cursor to the window above (horizontal split) |
| Ctrl + wH | make current window full height at far left (leftmost vertical window) |
| Ctrl + wL | make current window full height at far right (rightmost vertical window) |
| Ctrl + wJ | make current window full width at the very bottom (bottommost horizontal window) |
| Ctrl + wK | make current window full width at the very top (topmost horizontal window) |
Diff
| Command | Description |
| zf | manually define a fold up to motion |
| ss | split document to two windows |
| zd | delete fold under the cursor |
| za | toggle fold under the cursor |
| zo | open fold under the cursor |
| zc | close fold under the cursor |
| zr | reduce (open) all folds by one level |
| zm | fold more (close) all folds by one level |
| zi | toggle folding functionality |
| ]c | jump to start of next change |
| [c | jump to start of previous change |
| do or :diffg[et] | obtain (get) difference (from other buffer) |
| dp or :diffpu[t] | put difference (to other buffer) |
| :diffthis | make current window part of diff |
| :dif[fupdate] | update differences |
| :diffo[ff] | switch off diff mode for current window |
Advanced tips
| Command | Description |
| /hello | search hello |
| ?hello | search backward |
| /vhello | search all characters |
| :.,$d | from the current line(.) to the end of the file($) delete(d) |
| :g/hello/d | delete all line that containing 'hello' |
| :g!/hello/d | delete all lines not containing 'hello' |
| :%S/:/:^M/g | add new lines after the line that containing: |
| :%s/hello/other/g | replace all |
| :s/hee/other/g | replace in visual mode |
Note
to enter "^M" press ctrl+v -> M
Note
press 'n' to jump to next match
Web Sites