9 [Vim](http://www.vim.org/) is a very efficient text editor. This reference was made for Vim 8.0.
10 For shortcut notation, see `:help key-notation`.
20 | Shortcut | Description |
21 | -------------- | -------------------------------- |
23 | `:qa` | Close all files |
26 | `:wq` _/_ `:x` | Save and close file |
28 | `ZZ` | Save and quit |
29 | `ZQ` | Quit without checking changes |
34 | Shortcut | Description |
36 | `h` `j` `k` `l` | Arrow keys |
37 | `<C-U>` _/_ `<C-D>` | Half-page up/down |
38 | `<C-B>` _/_ `<C-F>` | Page up/down |
43 | Shortcut | Description |
45 | `b` _/_ `w` | Previous/next word |
46 | `ge` _/_ `e` | Previous/next end of word |
51 | Shortcut | Description |
53 | `0` _(zero)_ | Start of line |
54 | `^` | Start of line _(after whitespace)_ |
60 | `fc` | Go forward to character `c` |
61 | `Fc` | Go backward to character `c` |
66 | Shortcut | Description |
70 | `:{number}` | Go to line `{number}` |
71 | `{number}G` | Go to line `{number}` |
72 | `{number}j` | Go down `{number}` lines |
73 | `{number}k` | Go up `{number}` lines |
78 | Shortcut | Description |
80 | `zz` | Center this line |
81 | `zt` | Top this line |
82 | `zb` | Bottom this line |
83 | `H` | Move to top of screen |
84 | `M` | Move to middle of screen |
85 | `L` | Move to bottom of screen |
90 | Shortcut | Description |
92 | `n` | Next matching search pattern |
93 | `N` | Previous match |
94 | `*` | Next whole word under cursor |
95 | `#` | Previous whole word under cursor |
100 | Shortcut | Description |
102 | `:tabedit [file]` | Edit file in a new tab |
103 | `:tabfind [file]` | Open file if exists in new tab |
104 | `:tabclose` | Close current tab |
105 | `:tabs` | List all tabs |
106 | `:tabfirst` | Go to first tab |
107 | `:tablast` | Go to last tab |
108 | `:tabn ` | Go to next tab |
109 | `:tabp ` | Go to previous tab |
113 | Shortcut | Description |
116 | `A` | Append from end of line |
119 | `O` | Previous line |
121 | `s` | Delete char and insert |
122 | `S` | Delete line and insert |
123 | `C` | Delete until end of line and insert |
125 | `r` | Replace one character |
126 | `R` | Enter Replace mode |
128 | `u` | Undo changes |
129 | `<C-R>` | Redo changes |
132 ### Exiting insert mode
134 | Shortcut | Description |
136 | `Esc` _/_ `<C-[>` | Exit insert mode |
137 | `<C-C>` | Exit insert mode, and abort current command |
142 | Shortcut | Description |
144 | `x` | Delete character |
146 | `dd` | Delete line _(Cut)_ |
147 | `yy` | Yank line _(Copy)_ |
150 | `P` | Paste before |
152 | `"*p` _/_ `"+p` | Paste from system clipboard |
153 | `"*y` _/_ `"+y` | Paste to system clipboard |
158 | Shortcut | Description |
160 | `v` | Enter visual mode |
161 | `V` | Enter visual line mode |
162 | `<C-V>` | Enter visual block mode |
167 | Shortcut | Description |
169 | `d` _/_ `x` | Delete selection |
170 | `s` | Replace selection |
171 | `y` | Yank selection _(Copy)_ |
174 See [Operators](#operators) for other things you can do.
178 | Shortcut | Description |
180 | :%s/foo/bar/g | Replace foo with bar in whole document |
189 Operators let you operate in a range of text (defined by *motion*). These are performed in normal mode.
193 | Operator | Motion |
198 | Shortcut | Description |
201 | `y` | Yank _(copy)_ |
202 | `c` | Change _(delete then insert)_ |
204 | `>` | Indent right |
205 | `<` | Indent left |
212 | `!` | Filter through external program |
219 Combine operators with *motions* to use them.
222 | Shortcut | Description |
224 | `d`_d_ | _(repeat the letter)_ Delete current line |
225 | `d`_w_ | Delete to next word |
226 | `d`_b_ | Delete to beginning of word |
227 | _2_`dd` | Delete 2 lines |
228 | `d`_ip_ | Delete a text object _(inside paragraph)_ |
229 | _(in visual mode)_ `d` | Delete selection |
231 See: `:help motion.txt`
240 Text objects let you operate (with an *operator*) in or around text blocks (*objects*).
244 | Operator | [i]nside or [a]round | Text object |
249 | Shortcut | Description |
255 | `[` `(` `{` `<` | A [], (), or {} block |
256 | `'` `"` <code>`</code> | A quoted string |
259 | `B` | A block in [{ |
260 | `t` | A XML tag block |
265 | Shortcut | Description |
267 | `vip` | Select paragraph |
268 | `vipipipip` | Select more |
270 | `yip` | Yank inner paragraph |
271 | `yap` | Yank paragraph (including newline) |
273 | `dip` | Delete inner paragraph |
274 | `cip` | Change inner paragraph |
277 See [Operators](#operators) for other things you can do.
281 | Shortcut | Description |
283 | `gvimdiff file1 file2 [file3]` | See differences between files, in HMI |
291 | Shortcut | Description |
293 | `zo` _/_ `zO` | Open |
294 | `zc` _/_ `zC` | Close |
295 | `za` _/_ `zA` | Toggle |
297 | `zv` | Open folds for this line |
302 | `zm` | Fold more _(foldlevel += 1)_ |
303 | `zr` | Fold less _(foldlevel -= 1)_ |
305 | `zx` | Update folds |
308 Uppercase ones are recursive (eg, `zO` is open recursively).
312 | Shortcut | Description |
314 | `%` | Nearest/matching `{[()]}` |
315 | `[(` `[{` `[<` | Previous `(` or `{` or `<` |
318 | `[m` | Previous method start |
319 | `[M` | Previous method end |
324 | Shortcut | Description |
326 | `<C-O>` | Go back to previous location |
327 | `<C-I>` | Go forward |
329 | `gf` | Go to file in cursor |
334 | Shortcut | Description |
336 | `<C-A>` | Increment number |
337 | `<C-X>` | Decrement |
342 | `z{height}<Cr>` | Resize pane to `{height}` lines tall |
346 | Shortcut | Description |
348 | `:tag Classname` | Jump to first definition of Classname |
350 | `<C-]>` | Jump to definition |
351 | `g]` | See all definitions |
352 | `<C-T>` | Go back to last tag |
353 | `<C-O> <C-I>` | Back/forward |
355 | `:tselect Classname` | Find definitions of Classname |
356 | `:tjump Classname` | Find definitions of Classname (auto-select 1st) |
361 | Shortcut | Description |
363 | `~` | Toggle case (Case => cASE) |
367 | `gUU` | Uppercase current line (also `gUgU`) |
368 | `guu` | Lowercase current line (also `gugu`) |
371 Do these in visual or normal mode.
375 | Shortcut | Description |
377 | <code>`^</code> | Last position of cursor in insert mode |
378 | <code>`.</code> | Last change in current buffer |
379 | <code>`"</code> | Last exited current buffer |
380 | <code>`0</code> | In last file edited |
381 | <code>''</code> | Back to line in current buffer where jumped from |
382 | <code>``</code> | Back to position in current buffer where jumped from |
383 | <code>`[</code> | To beginning of previously changed or yanked text |
384 | <code>`]</code> | To end of previously changed or yanked text |
385 | <code>`<</code> | To beginning of last visual selection |
386 | <code>`></code> | To end of last visual selection |
388 | `ma` | Mark this cursor position as `a` |
389 | <code>`a</code> | Jump to the cursor position `a` |
390 | `'a` | Jump to the beginning of the line with position `a` |
391 | <code>d'a</code> | Delete from current line to line of mark `a` |
392 | <code>d`a</code> | Delete from current position to position of mark `a` |
393 | <code>c'a</code> | Change text from current line to line of `a` |
394 | <code>y`a</code> | Yank text from current position to position of `a` |
396 | `:marks` | List all current marks |
397 | `:delm a` | Delete mark `a` |
398 | `:delm a-d` | Delete marks `a`, `b`, `c`, `d` |
399 | `:delm abc` | Delete marks `a`, `b`, `c` |
404 | Shortcut | Description |
406 | `.` | Repeat last command |
407 | `]p` | Paste under the current indentation level |
409 | `:set ff=unix` | Convert Windows line endings to Unix line endings |
414 | Shortcut | Description |
416 | `<C-R><C-W>` | Insert current word into the command line |
417 | `<C-R>"` | Paste from " register |
418 | `<C-X><C-F>` | Auto-completion of path in insert mode |
427 See `:help formatting`
431 | Shortcut | Description |
433 | `<C-R>=128/2` | Shows the result of the division : '64' |
435 Do this in insert mode.
437 ### Exiting with an error
442 Works like `:qa`, but throws an error. Great for aborting Git commands.
447 | Shortcut | Description |
449 | `:set spell spelllang=en_us` | Turn on US English spell checking |
450 | `]s` | Move to next misspelled word after the cursor |
451 | `[s` | Move to previous misspelled word before the cursor |
452 | `z=` | Suggest spellings for the word under/after the cursor |
453 | `zg` | Add word to spell list |
454 | `zw` | Mark word as bad/mispelling |
455 | `zu` / `C-X (Insert Mode)` | Suggest words for bad word under cursor from spellfile |
464 - [Vim cheatsheet](https://vim.rtorr.com/) _(vim.rotrr.com)_
465 - [Vim documentation](http://vimdoc.sourceforge.net/htmldoc/) _(vimdoc.sourceforge.net)_
466 - [Interactive Vim tutorial](http://openvim.com/) _(openvim.com)_