Vim cheatsheet
I’ve been using Vim heavily in the last two month. In order to not waste a lot of time looking up a certain feature or key combination, I came up with the idea to create a cheatsheet page for that.
So here it is. I hope you’ll find something useful here too ;)
CLI
vim +PluginInstall
open Vim and run command
Splits
- Move split window:
<c-w> H
left<c-w> J
down<c-w> K
up<c-w> L
right
QuickFix list
QuickFix list contains the list of items. For example, if you use YouCompleteMe to find all the variable references, the result is populated into the QuickFix list. The following commands are used to manage the list:
:copen
open the list:cclose
close the list:cnext
go to the next item:cprev
go to the previous item:colder
open the previous content of QuickFix (yes, it has history):cnewer
open the next context of QuickFix
Tabs
gt
go to the next tabgT
go to the previous tab5gt
go to tab 5<c-w> T
open current buffer in the new tab:tabedit
open file for editing in a new tab
Diff
:diffget
obtain changes from the other file:diffput
apply changes to the other file
Folds
- Go to:
zk
the previous foldzj
the next fold
zm
fold one level morezM
close all foldszr
reduce folding by one levelzR
open all foldszc
close one fold under the cursorzC
close all folds under the cursor recursivelyzo
open one fold under the cursorzO
open all folds under the cursor recursively
Positioning in the file
- Position the current line in:
zt
the top of the windowzz
the middle of the windowzb
the bottom of the window
CtrlSF
<c-c>
stop the searcht
open file in a new tabT
open file in a new tab, but keep focus on CtrlSFM
switch view mode (horizontal or vertical)
vim-signify
[c
go to the previous change]c
go to the next change