vim cheatsheet
Vim macro recording
Start recording by q + <letter>
and you can end it by typing q
again, replay by typing @ + <letter>
.
stock
C-t
: new tab<leader><tab>
: switch tab<leader><s-tab>
: switch tab<leader>p/d
: paste/delete without polutting clipboard<leader>s
: replace the word where cursor is on<leader>t
: toggle alternate<leader>x
: add execute permission to current file<leader>D
: toggle diagnostics<leader>L
: toggle list spaces and line delimiters<leader>W
: toggle wrap<C-j><C-j>
: exit terminal buffer insert mode<C-j><C-j>
: exit insert mode<C-j><C-j>
: quicker exit and save<C-k><C-k>
: quicker exit without saving
conform.nvim
<leader>F
: ConformFormat<leader>S
: ConformSpell
vim-fugitive + gitsigns.nvim
<leader>G
: Fugitive<leader>hs
: stage_hunk<leader>hu
: undo_stage_hunk<leader>hr
: reset_hunk<leader>hp
: preview_hunk<leader>hS
: stage_buffer<leader>hR
: reset_buffer<leader>hb
: toggle_current_line_blame<leader>hd
: diffthis
fzf-lua
<leader>ff
: fzflua.files<leader>fg
: fzflua.live_grep<leader>fG
: fzflua.grep<leader>fh
: fzflua.command_history<leader>H
: fzflua.command_history<leader>:
: fzflua.commands
harpoon
<leader>M
: mark.add_file<leader>m
: ui.toggle_quick_menu<C-k>
: ui.nav_prev<C-j>
: ui.nav_next
Packer
<leader><leader><leader>
: PackerSync
hop.nvim
<leader>l
: HopLineStart<leader>w
: HopWord<leader>/
: HopPattern
nvim-terminal
<C-z>
: toggle terminal<leader>1-5
: toggle terminal<leader><leader>+
: increase terminal width<leader><leader>-
: decrease terminal width<leader>+
: increase terminal height<leader>-
: decrease terminal height
nvim-tree.lua
<C-n>
: NvimTreeToggle<C-N>
: NvimTreeFindFileToggle
undotree
<leader>u
: UndotreeToggle
nerdcommenter
<leader>c<space>
: NERDCommenterToggle<leader>cc
: NERDCommenterComment<leader>cu
: NERDCommenterUncomment<leader>ci
: NERDCommenterInvert<leader>cs
: NERDCommenterSexy<leader>cm
: NERDCommenterMinimal<leader>cy
: NERDCommenterYank<leader>cn
: NERDCommenterNested<leader>ca
: NERDCommenterAltDelims<leader>c$
: NERDCommenterToEOL<leader>cA
: NERDCommenterAppend
vim-folding
za
toggle current foldzA
recursively toggle current foldzo
open current foldzO
recursively open current foldzc
close current foldzC
recursively close current foldzR
open all foldszM
close all foldszr
decreases the foldlevel by onezm
increases the foldlevel by one[z
move to start of open fold]z
move to end of open foldzf#j
creates a fold from the cursor down # lineszf/string
creates a fold from the cursor to stringzE
delete all foldszd
delete the fold at the cursorzi
switch folding on or offzj
move down to top of next foldzk
move up to bottom of previous foldzv
expand folds to reveal cursor
comment-box.nvim
Command | Description | function |
---|---|---|
CBllbox[num] | Left aligned box of fixed size with Left aligned text | require("comment-box").llbox([num]) |
CBlcbox[num] | Left aligned box of fixed size with Centered text | require("comment-box").lcbox([num]) |
CBlrbox[num] | Left aligned box of fixed size with Right aligned text | require("comment-box").lrbox([num]) |
CBclbox[num] | Centered box of fixed size with Left aligned text | require("comment-box").lcbox([num]) |
CBccbox[num] | Centered box of fixed size with Centered text | require("comment-box").ccbox([num]) |
CBcrbox[num] | Centered box of fixed size with Right aligned text | require("comment-box").crbox([num]) |
CBrlbox[num] | Right aligned box of fixed size with Left aligned text | require("comment-box").rlbox([num]) |
CBrcbox[num] | Right aligned box of fixed size with Centered text | require("comment-box").rcbox([num]) |
CBrrbox[num] | Right aligned box of fixed size with Right aligned text | require("comment-box").rrbox([num]) |
CBalbox[num] | Left aligned adapted box | require("comment-box").albox([num]) |
CBacbox[num] | Centered adapted box | require("comment-box").acbox([num]) |
CBarbox[num] | Right aligned adapted box | require("comment-box").arbox([num]) |
vim-peekaboo
"
or @
in normal mode, <CTRL-R>
in insert mode, toggle fullscreen by pressing <space>
IndentWise
[-
: Move to previous line of lesser indent than the current line.[+
: Move to previous line of greater indent than the current line.[=
: Move to previous line of same indent as the current line that is separated from the current line by lines of different indents.]-
: Move to next line of lesser indent than the current line.]+
: Move to next line of greater indent than the current line.]=
: Move to next line of same indent as the current line that is separated from the current line by lines of different indents.{count}[_
: Move to previous line with indent-level of{count}
.{count}]_
: Move to next line with indent-level of{count}
.
vim-easy-align
single character, such as <Space>
, =
, :
, .
, |
, &
, #
, and ,
.
=
=
Around the 1st occurrences2=
Around the 2nd occurrences*=
Around all occurrences**=
Left/Right alternating alignment around all occurrences<Enter>
Switching between left/right/center alignment modes
<space>
<Space>
Around the 1st occurrences of whitespaces2<Space>
Around the 2nd occurrences-<Space>
Around the last occurrences<Enter><Enter>2<Space>
Center-alignment around the 2nd occurrences
, <comma>
- The predefined comma-rule places a comma right next to the preceding token without margin (
{'stick_to_left': 1, 'left_margin': 0}
) - You can change it with
<Right>
arrow
vim-sandwitch
Add: Press
sa{motion/textobject}{addition}
. For example, a key sequencesaiw(
makes foo to (foo).Delete: Press
sdb
orsd{deletion}
. For example, key sequencessdb
orsd(
makes (foo) to foo.sdb
searches a set of surrounding automatically.Replace: Press
srb{addition}
orsr{deletion}{addition}
. For example, key sequencessrb"
orsr("
makes (foo) to “foo”.
This post is licensed under CC BY 4.0 by the author.