CeDeT: OUR (Often Used Reference) #5
Vi(m) Quick Key ReferenceVI
|
|
| Cursor movement | |
|---|---|
| Keys | Actions |
| ↑, ↓, ←, → | Move up, down, left and right |
| k, j, h, l | Move up, down, left and right |
| w, b | Scroll by word foward, backward |
| (, ) | Scroll by sentence forward, backward |
| 0, $ | Go to beginning, end of line |
| Ctrl+u, Ctrl+d | Scroll up, down half screen |
| Ctrl+f, Ctrl+b | Scroll forward, backward full screen |
| G, n G | Go to last, n'th line |
| Deleting, copying and pasting text | |
|---|---|
| Keys | Action |
| x | Delete text at cursor |
| dw | Delete word under cursor |
| r | Replace character under cursor |
| dd, yy | Delete, copy line |
| n dd, yy | Delete, copy n lines |
| p, P | Paste after, before |
| J | Join lines |
| guw | Change word under cursor to lower case (vim) |
| gUw | Change word under cursor to Upper case (vim) |
| Misc | |
|---|---|
| Keys | Action |
| u | Undo previous command |
| U | Undo all changes to line |
| n | Find next, previous search pattern occurrence |
| Inserting text | |
|---|---|
| Keys | Action |
| i, I | Insert text at cursor, beginning of line |
| a, A | Append text at cursor, end of line |
| o, O | Open line below, above cursor |
| cw | Change word under cursor |
| Esc | End insert mode (return to normal) |
| Command modes | |
|---|---|
| Command | Action |
| :, ! command | Enter ex, filter command |
| /, ? pattern | Search forward, backward for pattern |
| Enter | Execute command or search (return to normal) |
| Delete, copy and paste | |
|---|---|
| Command | Action |
| :m,n d | Delete lines m-n |
| :m,n t p | Copy lines m to n, paste after line p |
| :m,n m p | Delete lines m to n, paste after line p |
| Files | |
|---|---|
| Command | Action |
| :w | Write (save changes) |
| :w file | Write to (new) file |
| :m,n w file | Save lines m-n to (new) file |
| :q | Quit |
| :wq | Write and quit |
| :q! | Force quit (discarding changes) |
| :e file | Edit (new) file |
| :e! file | Force edit (new) file (discarding changes) |
| Search and replace | |
|---|---|
| Command | :%s/search-pattern/replace-pattern/cg |
| Action | Search all lines (%) globally (g) for search-pattern and confirm (c) replace with replace-pattern |
| Options | |
|---|---|
| Command | Action |
| :set all | Displays all options |
| :set noopt | Toggles option (opt) off |
| :set nu | Displays line numbers |
| :set ic | Ignores case during search |
| :set showmode | Displays insert mode |
| :set expandtab | Expand to tab position with spaces, not the tab character |
| :set guifont=font-name:hheight-in-pts | Sets the specified font (choose a monospaced one), example (vim) set guifont=Consolas:h9 |
Hint
The settings you want enabled/disabled by default can be set in the vim configuration file - on my machine (for vim version 6.4) it isC:\Programmer\Vim\vim64\vimrc_example.vim