(Most of the stuff in here comes from these guides)
- 10 essential Vim plugins for 2018
- Top 10 Vim plugins for programming in multiple languages
- How I boosted my Vim
- The standard Vim Leader key is the
\
character. - Close all buffers and quit:
:qa
- Save all buffers and quit:
:wqa
- To run terminal commands:
:!command
- New tab:
tabnew
orCTRL+t
(if using my.vimrc
file) - Close tab:
tabc
- Next tab:
gt
- Prior tab:
gT
- Numbered tab:
tabnumber gt
- Close all other tabs:
:tabo
or:tabonly
Ctrl+W v
: split verticallyCtrl+W s
: split horizontally
Ctrl+W hjkl
: change focus of current windows splithjkl
are the keys that vim uses instead of the arrow keys (h = left, j = bottom, k = up, l = right)
Ctrl+W HJKL
: move current window split- Note the uppercase, meaning you have to use shift+h, for example.
Ctrl+W +/-
: increase/decrease height (ex. 20+)Ctrl+W >/<
: increase/decrease width (ex. 30<)Ctrl+W _
: set height (ex. 50_)Ctrl+W |
: set width (ex. 50|)Ctrl+W =
: equalize width and height of all windows
You can also use the resize commands:
:resize [+-]N
: resize a horizontal split, increasing or decreasing height by N characters.:vertical resize [+-]N
: resize a vertical split, increasing or decreasing height by N characters.:resize N
: resize a horizontal split, setting height to N characters.:vertical resize N
: resize a vertical split, setting width to N characters.
To make a basic selection, use the Ctrl+N
keystroke in normal mode, followed by a motion:
c
– change text.I
– insert at start of range.A
– insert at end of range.
More actions can be found in the plugin’s quick start information.
This cryptically-named plugin adds a dozen core Unix file operations as Vim commands in the context of the current file.
:Rename new_name.sh
:Chmod +x
:SudoWrite
It's easier to just check the project examples: https://github.com/tpope/vim-surround
To jump between changes and stage/discard individual hunks:
]c
: GitGutterNextHunk[c
: GitGutterPrevHunk<Leader>hs
: GitGutterStageHunk<Leader>hu
: GitGutterUndoHunk
Leader+cc
: Comment out the current line or text selected in visual mode.Leader+cn
: Same as cc but forces nesting.Leader+c<space>
: Toggles the comment state of the selected line(s). If the topmost selected line is commented, all selected lines are uncommented and vice versa.Leader+cm
:Comments the given lines using only one set of multipart delimiters.Leader+cs
:Comments out the selected lines with a pretty block formatted layout.
Search pattern in files.
:Ack [options] {pattern} [{directories}]