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>` | 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 |
105 | `A` | Append from end of line |
108 | `O` | Previous line |
110 | `s` | Delete char and insert |
111 | `S` | Delete line and insert |
112 | `C` | Delete until end of line and insert |
114 | `r` | Replace one character |
115 | `R` | Enter Replace mode |
117 | `u` | Undo changes |
118 | `<C-R>` | Redo changes |
121 ### Exiting insert mode
123 | Shortcut | Description |
125 | `Esc` _/_ `<C-[>` | Exit insert mode |
126 | `<C-C>` | Exit insert mode, and abort current command |
131 | Shortcut | Description |
133 | `x` | Delete character |
135 | `dd` | Delete line _(Cut)_ |
136 | `yy` | Yank line _(Copy)_ |
139 | `P` | Paste before |
141 | `"*p` _/_ `"+p` | Paste from system clipboard |
142 | `"*y` _/_ `"+y` | Paste to system clipboard |
147 | Shortcut | Description |
149 | `v` | Enter visual mode |
150 | `V` | Enter visual line mode |
151 | `<C-V>` | Enter visual block mode |
156 | Shortcut | Description |
158 | `d` _/_ `x` | Delete selection |
159 | `s` | Replace selection |
160 | `y` | Yank selection _(Copy)_ |
163 See [Operators](#operators) for other things you can do.
172 Operators let you operate in a range of text (defined by *motion*). These are performed in normal mode.
176 | Operator | Motion |
181 | Shortcut | Description |
184 | `y` | Yank _(copy)_ |
185 | `c` | Change _(delete then insert)_ |
187 | `>` | Indent right |
188 | `<` | Indent left |
194 | `!` | Filter through external program |
201 Combine operators with *motions* to use them.
204 | Shortcut | Description |
206 | `d`_d_ | _(repeat the letter)_ Delete current line |
207 | `d`_w_ | Delete to next word |
208 | `d`_b_ | Delete to beginning of word |
209 | _2_`dd` | Delete 2 lines |
210 | `d`_ip_ | Delete a text object _(inside paragraph)_ |
211 | _(in visual mode)_ `d` | Delete selection |
213 See: `:help motion.txt`
222 Text objects let you operate (with an *operator*) in or around text blocks (*objects*).
226 | Operator | [i]nside or [a]round | Text object |
231 | Shortcut | Description |
237 | `[` `(` `{` `<` | A [], (), or {} block |
238 | `'` `"` <code>`</code> | A quoted string |
241 | `B` | A block in [{ |
242 | `t` | A XML tag block |
247 | Shortcut | Description |
249 | `vip` | Select paragraph |
250 | `vipipipip` | Select more |
252 | `yip` | Yank inner paragraph |
253 | `yap` | Yank paragraph (including newline) |
255 | `dip` | Delete inner paragraph |
256 | `cip` | Change inner paragraph |
259 See [Operators](#operators) for other things you can do.
263 | Shortcut | Description |
265 | `gvimdiff file1 file2 [file3]` | See differences between files, in HMI |
273 | Shortcut | Description |
275 | `zo` _/_ `zO` | Open |
276 | `zc` _/_ `zC` | Close |
277 | `za` _/_ `zA` | Toggle |
279 | `zv` | Open folds for this line |
284 | `zm` | Fold more _(foldlevel += 1)_ |
285 | `zr` | Fold less _(foldlevel -= 1)_ |
287 | `zx` | Update folds |
290 Uppercase ones are recursive (eg, `zO` is open recursively).
294 | Shortcut | Description |
296 | `%` | Nearest/matching `{[()]}` |
297 | `[(` `[{` `[<` | Previous `(` or `{` or `<` |
300 | `[m` | Previous method start |
301 | `[M` | Previous method end |
306 | Shortcut | Description |
308 | `<C-O>` | Go back to previous location |
309 | `<C-I>` | Go forward |
311 | `gf` | Go to file in cursor |
316 | Shortcut | Description |
318 | `<C-A>` | Increment number |
319 | `<C-X>` | Decrement |
324 | `z{height}<Cr>` | Resize pane to `{height}` lines tall |
328 | Shortcut | Description |
330 | `:tag Classname` | Jump to first definition of Classname |
332 | `<C-]>` | Jump to definition |
333 | `g]` | See all definitions |
334 | `<C-T>` | Go back to last tag |
335 | `<C-O> <C-I>` | Back/forward |
337 | `:tselect Classname` | Find definitions of Classname |
338 | `:tjump Classname` | Find definitions of Classname (auto-select 1st) |
343 | Shortcut | Description |
345 | `~` | Toggle case (Case => cASE) |
349 | `gUU` | Uppercase current line (also `gUgU`) |
350 | `guu` | Lowercase current line (also `gugu`) |
353 Do these in visual or normal mode.
357 | Shortcut | Description |
359 | <code>`^</code> | Last position of cursor in insert mode |
360 | <code>`.</code> | Last change |
361 | <code>``</code> | Last jump |
363 | `ma` | Mark this cursor position as `a` |
364 | <code>`a</code> | Jump to the cursor position `a` |
365 | `'a` | Jump to the beginning of the line with position `a`|
370 | Shortcut | Description |
372 | `.` | Repeat last command |
373 | `]p` | Paste under the current indentation level |
375 | `:set ff=unix` | Convert Windows line endings to Unix line endings |
380 | Shortcut | Description |
382 | `<C-R><C-W>` | Insert current word into the command line |
383 | `<C-R>"` | Paste from " register |
384 | `<C-X><C-F>` | Auto-completion of path in insert mode |
393 See `:help formatting`
397 | Shortcut | Description |
399 | `<C-R>=128/2` | Shows the result of the division : '64' |
401 Do this in insert mode.
403 ### Exiting with an error
408 Works like `:qa`, but throws an error. Great for aborting Git commands.
413 | Shortcut | Description |
415 | `:set spell spelllang=en_us` | Turn on US English spell checking |
416 | `]s` | Move to next misspelled word after the cursor |
417 | `[s` | Move to previous misspelled word before the cursor |
418 | `z=` | Suggest spellings for the word under/after the cursor |
419 | `zg` | Add word to spell list |
420 | `zw` | Mark word as bad/mispelling |
421 | `zu` / `C-X (Insert Mode)` | Suggest words for bad word under cursor from spellfile |
430 - [Vim cheatsheet](https://vim.rtorr.com/) _(vim.rotrr.com)_
431 - [Vim documentation](http://vimdoc.sourceforge.net/htmldoc/) _(vimdoc.sourceforge.net)_
432 - [Interactive Vim tutorial](http://openvim.com/) _(openvim.com)_