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 | -------------- | -------------------------------- |
22 | `:qa` | Close all files |
23 | `:qa!` | Close all files, abandon changes |
26 | `:wq` _/_ `:x` | Save and close file |
29 | `:q!` | Close file, abandon changes |
31 | `ZZ` | Save and quit |
32 | `ZQ` | Quit without checking changes |
37 | Shortcut | Description |
39 | `h` `j` `k` `l` | Arrow keys |
40 | `<C-U>` _/_ `<C-D>` | Half-page up/down |
41 | `<C-B>` _/_ `<C-F>` | Page up/down |
46 | Shortcut | Description |
48 | `b` _/_ `w` | Previous/next word |
49 | `ge` _/_ `e` | Previous/next end of word |
54 | Shortcut | Description |
56 | `0` _(zero)_ | Start of line |
57 | `^` | Start of line _(after whitespace)_ |
63 | `fc` | Go forward to character `c` |
64 | `Fc` | Go backward to character `c` |
69 | Shortcut | Description |
73 | `:n` | Go to line `n` |
74 | `nG` | Go to line `n` |
79 | Shortcut | Description |
81 | `zz` | Center this line |
82 | `zt` | Top this line |
83 | `zb` | Bottom this line |
84 | `H` | Move to top of screen |
85 | `M` | Move to middle of screen |
86 | `L` | Move to bottom of screen |
91 | Shortcut | Description |
93 | `n` | Next matching search pattern |
94 | `N` | Previous match |
95 | `*` | Next whole word under cursor |
96 | `#` | Previous whole word under cursor |
101 | Shortcut | Description |
103 | `:tabedit [file]` | Edit file in a new tab |
104 | `:tabfind [file]` | Open file if exists in new tab |
105 | `:tabclose` | Close current tab |
106 | `:tabs` | List all tabs |
107 | `:tabfirst` | Go to first tab |
108 | `:tablast` | Go to last tab |
109 | `:tabn ` | Go to next tab |
110 | `:tabp ` | Go to previous tab |
114 | Shortcut | Description |
117 | `A` | Append from end of line |
120 | `O` | Previous line |
122 | `s` | Delete char and insert |
123 | `S` | Delete line and insert |
124 | `C` | Delete until end of line and insert |
126 | `r` | Replace one character |
127 | `R` | Enter Replace mode |
129 | `u` | Undo changes |
130 | `<C-R>` | Redo changes |
133 ### Exiting insert mode
135 | Shortcut | Description |
137 | `Esc` _/_ `<C-[>` | Exit insert mode |
138 | `<C-C>` | Exit insert mode, and abort current command |
143 | Shortcut | Description |
145 | `x` | Delete character |
147 | `dd` | Delete line _(Cut)_ |
148 | `yy` | Yank line _(Copy)_ |
151 | `P` | Paste before |
153 | `"*p` _/_ `"+p` | Paste from system clipboard |
154 | `"*y` _/_ `"+y` | Paste to system clipboard |
159 | Shortcut | Description |
161 | `v` | Enter visual mode |
162 | `V` | Enter visual line mode |
163 | `<C-V>` | Enter visual block mode |
168 | Shortcut | Description |
170 | `d` _/_ `x` | Delete selection |
171 | `s` | Replace selection |
172 | `y` | Yank selection _(Copy)_ |
175 See [Operators](#operators) for other things you can do.
184 Operators let you operate in a range of text (defined by *motion*). These are performed in normal mode.
188 | Operator | Motion |
193 | Shortcut | Description |
196 | `y` | Yank _(copy)_ |
197 | `c` | Change _(delete then insert)_ |
199 | `>` | Indent right |
200 | `<` | Indent left |
207 | `!` | Filter through external program |
214 Combine operators with *motions* to use them.
217 | Shortcut | Description |
219 | `d`_d_ | _(repeat the letter)_ Delete current line |
220 | `d`_w_ | Delete to next word |
221 | `d`_b_ | Delete to beginning of word |
222 | _2_`dd` | Delete 2 lines |
223 | `d`_ip_ | Delete a text object _(inside paragraph)_ |
224 | _(in visual mode)_ `d` | Delete selection |
226 See: `:help motion.txt`
235 Text objects let you operate (with an *operator*) in or around text blocks (*objects*).
239 | Operator | [i]nside or [a]round | Text object |
244 | Shortcut | Description |
250 | `[` `(` `{` `<` | A [], (), or {} block |
251 | `'` `"` <code>`</code> | A quoted string |
254 | `B` | A block in [{ |
255 | `t` | A XML tag block |
260 | Shortcut | Description |
262 | `vip` | Select paragraph |
263 | `vipipipip` | Select more |
265 | `yip` | Yank inner paragraph |
266 | `yap` | Yank paragraph (including newline) |
268 | `dip` | Delete inner paragraph |
269 | `cip` | Change inner paragraph |
272 See [Operators](#operators) for other things you can do.
276 | Shortcut | Description |
278 | `gvimdiff file1 file2 [file3]` | See differences between files, in HMI |
286 | Shortcut | Description |
288 | `zo` _/_ `zO` | Open |
289 | `zc` _/_ `zC` | Close |
290 | `za` _/_ `zA` | Toggle |
292 | `zv` | Open folds for this line |
297 | `zm` | Fold more _(foldlevel += 1)_ |
298 | `zr` | Fold less _(foldlevel -= 1)_ |
300 | `zx` | Update folds |
303 Uppercase ones are recursive (eg, `zO` is open recursively).
307 | Shortcut | Description |
309 | `%` | Nearest/matching `{[()]}` |
310 | `[(` `[{` `[<` | Previous `(` or `{` or `<` |
313 | `[m` | Previous method start |
314 | `[M` | Previous method end |
319 | Shortcut | Description |
321 | `<C-O>` | Go back to previous location |
322 | `<C-I>` | Go forward |
324 | `gf` | Go to file in cursor |
329 | Shortcut | Description |
331 | `<C-A>` | Increment number |
332 | `<C-X>` | Decrement |
337 | `z{height}<Cr>` | Resize pane to `{height}` lines tall |
341 | Shortcut | Description |
343 | `:tag Classname` | Jump to first definition of Classname |
345 | `<C-]>` | Jump to definition |
346 | `g]` | See all definitions |
347 | `<C-T>` | Go back to last tag |
348 | `<C-O> <C-I>` | Back/forward |
350 | `:tselect Classname` | Find definitions of Classname |
351 | `:tjump Classname` | Find definitions of Classname (auto-select 1st) |
356 | Shortcut | Description |
358 | `~` | Toggle case (Case => cASE) |
362 | `gUU` | Uppercase current line (also `gUgU`) |
363 | `guu` | Lowercase current line (also `gugu`) |
366 Do these in visual or normal mode.
370 | Shortcut | Description |
372 | <code>`^</code> | Last position of cursor in insert mode |
373 | <code>`.</code> | Last change in current buffer |
374 | <code>`"</code> | Last exited current buffer |
375 | <code>`0</code> | In last file edited |
376 | <code>''</code> | Back to line in current buffer where jumped from |
377 | <code>``</code> | Back to position in current buffer where jumped from |
378 | <code>`[</code> | To beginning of previously changed or yanked text |
379 | <code>`]</code> | To end of previously changed or yanked text |
380 | <code>`<</code> | To beginning of last visual selection |
381 | <code>`></code> | To end of last visual selection |
383 | `ma` | Mark this cursor position as `a` |
384 | <code>`a</code> | Jump to the cursor position `a` |
385 | `'a` | Jump to the beginning of the line with position `a` |
386 | <code>d'a</code> | Delete from current line to line of mark `a` |
387 | <code>d`a</code> | Delete from current position to position of mark `a` |
388 | <code>c'a</code> | Change text from current line to line of `a` |
389 | <code>y`a</code> | Yank text from current position to position of `a` |
391 | `:marks` | List all current marks |
392 | `:delm a` | Delete mark `a` |
393 | `:delm a-d` | Delete marks `a`, `b`, `c`, `d` |
394 | `:delm abc` | Delete marks `a`, `b`, `c` |
399 | Shortcut | Description |
401 | `.` | Repeat last command |
402 | `]p` | Paste under the current indentation level |
404 | `:set ff=unix` | Convert Windows line endings to Unix line endings |
409 | Shortcut | Description |
411 | `<C-R><C-W>` | Insert current word into the command line |
412 | `<C-R>"` | Paste from " register |
413 | `<C-X><C-F>` | Auto-completion of path in insert mode |
422 See `:help formatting`
426 | Shortcut | Description |
428 | `<C-R>=128/2` | Shows the result of the division : '64' |
430 Do this in insert mode.
432 ### Exiting with an error
437 Works like `:qa`, but throws an error. Great for aborting Git commands.
442 | Shortcut | Description |
444 | `:set spell spelllang=en_us` | Turn on US English spell checking |
445 | `]s` | Move to next misspelled word after the cursor |
446 | `[s` | Move to previous misspelled word before the cursor |
447 | `z=` | Suggest spellings for the word under/after the cursor |
448 | `zg` | Add word to spell list |
449 | `zw` | Mark word as bad/mispelling |
450 | `zu` / `C-X (Insert Mode)` | Suggest words for bad word under cursor from spellfile |
459 - [Vim cheatsheet](https://vim.rtorr.com/) _(vim.rotrr.com)_
460 - [Vim documentation](http://vimdoc.sourceforge.net/htmldoc/) _(vimdoc.sourceforge.net)_
461 - [Interactive Vim tutorial](http://openvim.com/) _(openvim.com)_