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 |
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>` | Page up/page down |
45 | Shortcut | Description |
47 | `b` _/_ `w` | Previous/next word |
48 | `ge` _/_ `e` | Previous/next end of word |
53 | Shortcut | Description |
55 | `0` _(zero)_ | Start of line |
56 | `^` | Start of line _(after whitespace)_ |
62 | `fc` | Go forward to character `c` |
63 | `Fc` | Go backward to character `c` |
68 | Shortcut | Description |
72 | `:n` | Go to line `n` |
73 | `nG` | Go to line `n` |
78 | Shortcut | Description |
80 | `zz` | Center this line |
81 | `zt` | Top this line |
82 | `H` | Move to top of screen |
83 | `M` | Move to middle of screen |
84 | `L` | Move to bottom of screen |
89 | Shortcut | Description |
91 | `:tabedit [file]` | Edit file in a new tab |
92 | `:tabfind [file]` | Open file if exists in new tab |
93 | `:tabclose` | Close current tab |
94 | `:tabs` | List all tabs |
95 | `:tabfirst` | Go to first tab |
96 | `:tablast` | Go to last tab |
97 | `:tabn ` | Go to next tab |
98 | `:tabp ` | Go to previous tab |
102 | Shortcut | Description |
107 | `O` | Previous line |
109 | `s` | Delete char and insert |
110 | `S` | Delete line and insert |
111 | `C` | Delete until end of line and insert |
113 | `r` | Replace one character |
114 | `R` | Enter Replace mode |
116 | `u` | Undo changes |
117 | `<C-R>` | Redo changes |
120 ### Exiting insert mode
122 | Shortcut | Description |
124 | `Esc` _/_ `<C-[>` | Exit insert mode |
125 | `<C-C>` | Exit insert mode, and abort current command |
130 | Shortcut | Description |
132 | `x` | Delete character |
134 | `dd` | Delete line _(Cut)_ |
135 | `yy` | Yank line _(Copy)_ |
138 | `P` | Paste before |
143 | Shortcut | Description |
145 | `v` | Enter visual mode |
146 | `V` | Enter visual line mode |
147 | `<C-V>` | Enter visual block mode |
152 | Shortcut | Description |
154 | `d` _/_ `x` | Delete selection |
155 | `s` | Replace selection |
156 | `y` | Yank selection _(Copy)_ |
159 See [Operators](#operators) for other things you can do.
168 Operators let you operate in a range of text (defined by *motion*). These are performed in normal mode.
172 | Operator | Motion |
177 | Shortcut | Description |
180 | `y` | Yank _(copy)_ |
181 | `c` | Change _(delete then insert)_ |
183 | `>` | Indent right |
184 | `<` | Indent left |
190 | `!` | Filter through external program |
197 Combine operators with *motions* to use them.
200 | Shortcut | Description |
202 | `d`_d_ | _(repeat the letter)_ Delete current line |
203 | `d`_w_ | Delete to next word |
204 | `d`_b_ | Delete to beginning of word |
205 | _2_`dd` | Delete 2 lines |
206 | `d`_ip_ | Delete a text object _(inside paragraph)_ |
207 | _(in visual mode)_ `d` | Delete selection |
209 See: `:help motion.txt`
218 Text objects let you operate (with an *operator*) in or around text blocks (*objects*).
222 | Operator | [i]nside or [a]round | Text object |
227 | Shortcut | Description |
233 | `[` `(` `{` `<` | A [], (), or {} block |
234 | `'` `"` <code>`</code> | A quoted string |
237 | `B` | A block in [{ |
238 | `t` | A XML tag block |
243 | Shortcut | Description |
245 | `vip` | Select paragraph |
246 | `vipipipip` | Select more |
248 | `yip` | Yank inner paragraph |
249 | `yap` | Yank paragraph (including newline) |
251 | `dip` | Delete inner paragraph |
252 | `cip` | Change inner paragraph |
255 See [Operators](#operators) for other things you can do.
259 | Shortcut | Description |
261 | `gvimdiff file1 file2 [file3]` | See differencies between files, in HMI |
269 | Shortcut | Description |
271 | `zo` _/_ `zO` | Open |
272 | `zc` _/_ `zC` | Close |
273 | `za` _/_ `zA` | Toggle |
275 | `zv` | Open folds for this line |
280 | `zm` | Fold more _(foldlevel += 1)_ |
281 | `zr` | Fold less _(foldlevel -= 1)_ |
283 | `zx` | Update folds |
286 Uppercase ones are recursive (eg, `zO` is open recursively).
290 | Shortcut | Description |
292 | `[(` `[{` `[<` | Previous `(` or `{` or `<` |
295 | `[m` | Previous method start |
296 | `[M` | Previous method end |
301 | Shortcut | Description |
303 | `<C-O>` | Go back to previous location |
304 | `<C-I>` | Go forward |
306 | `gf` | Go to file in cursor |
311 | Shortcut | Description |
313 | `<C-A>` | Increment number |
314 | `<C-X>` | Decrement |
319 | `z{height}<Cr>` | Resize pane to `{height}` lines tall |
323 | Shortcut | Description |
325 | `:tag Classname` | Jump to first definition of Classname |
327 | `<C-]>` | Jump to definition |
328 | `g]` | See all definitions |
329 | `<C-T>` | Go back to last tag |
330 | `<C-O> <C-I>` | Back/forward |
332 | `:tselect Classname` | Find definitions of Classname |
333 | `:tjump Classname` | Find definitions of Classname (auto-select 1st) |
338 | Shortcut | Description |
340 | `~` | Toggle case (Case => cASE) |
344 | `gUU` | Uppercase current line (also `gUgU`) |
345 | `guu` | Lowercase current line (also `gugu`) |
348 Do these in visual or normal mode.
352 | Shortcut | Description |
354 | <code>`^</code> | Last position of cursor in insert mode |
355 | <code>`.</code> | Last change |
356 | <code>``</code> | Last jump |
358 | `ma` | Mark this cursor position as `a` |
359 | <code>`a</code> | Jump to the cursor position `a` |
360 | `'a` | Jump to the beginning of the line with position `a`|
365 | Shortcut | Description |
367 | `.` | Repeat last command |
368 | `]p` | Paste under the current indentation level |
370 | `:ff=unix` | Convert Windows line endings to Unix line endings |
375 | Shortcut | Description |
377 | `<C-R><C-W>` | Insert current word into the command line |
378 | `<C-R>"` | Paste from " register |
379 | `<C-X><C-F>` | Auto-completion of path in insert mode |
388 See `:help formatting`
392 | Shortcut | Description |
394 | `<C-R>=128/2` | Shows the result of the division : '64' |
396 Do this in insert mode.
398 ### Exiting with an error
403 Works like `:qa`, but throws an error. Great for aborting Git commands.
408 | Shortcut | Description |
410 | `:set spell spelllang=en_us` | Turn on US English spell checking |
411 | `]s` | Move to next misspelled word after the cursor |
412 | `[s` | Move to previous misspelled word before the cursor |
413 | `z=` | Suggest spellings for the word under/after the cursor |
414 | `zg` | Add word to spell list |
415 | `zw` | Mark word as bad/mispelling |
416 | `zu` / `C-X (Insert Mode)` | Suggest words for bad word under cursor from spellfile |
425 - [Vim cheatsheet](https://vim.rtorr.com/) _(vim.rotrr.com)_
426 - [Vim documentation](http://vimdoc.sourceforge.net/htmldoc/) _(vimdoc.sourceforge.net)_
427 - [Interactive Vim tutorial](http://openvim.com/) _(openvim.com)_