I’ve been using Neovim for quite some time and have went through the entire Wiki. I would like to share some of my most loved tricks that have really skyrocketed my productivity.
Basic Navigation #
h
,l
~ Move left, right by one characterj
,k
~ Move down, up by one line+
,-
~ Move to the next/previous non-whitespace character on the line^
~ Move to the first non-whitespace character_
~ Move to the first character on the line (also takes a count)$
~ Move to the last character on the lineG
~ Move to the end of the filegg
~ Move to the beginning of the file40gg
~ Jump to line 40%
~ Jump to matching parenthesis or brackett{char}
~ Jump before the next occurrence of{char}
f{char}
~ Jump to the next occurrence of{char}
T{char}
/F{char}
~ Reverse oft
andf
,
and;
~ Repeatt
,T
,f
,F
in opposite/same direction
Searching #
/pattern
~ Search forward?pattern
~ Search backward#
and*
~ Search for the identifier under the cursor (backward/forward)/pattern/e
~ Place cursor on last character of pattern/pattern/e+1
~ Place cursor one character to the right of match/apple\C
~ Case-sensitive search:%s/pattern//n
~ Count occurrences of pattern/\%V
~ Search inside visual selection
Editing #
i
,I
~ Insert at cursor / start of linea
,A
~ Append after cursor / end of linegi
~ Insert at last edit positiono
,O
~ Open new line below / above and enter insert moder{char}
~ Replace character under cursorJ
~ Join line with next onegJ
~ Join lines without inserting spacexp
~ Swap two charactersD
,Y
,C
~ Instead ofd$
,y$
,c$
gq
~ Wrap long lines
Case Modification #
guu
/gUU
/g~~
~ Make current line lowercase, uppercase, or toggle casegu
,gU
,g~
~ Operator to change case
Copying & Deleting #
yy
/dd
~ Yank/Delete entire lineyib
~ Yank inside()
d/hello
~ Delete until “hello”d/hello/e
~ Delete up to and including “hello”dk
/dj
~ Delete current and previous/next linegp
/gP
~ Paste likep
/P
but leave cursor after pasted text
Visual Mode Tricks #
CTRL v
~ Visual block mode<
/>
~ Dedent/Indent selected textI
in visual block ~ Insert text at the beginning of each line$A
in visual block ~ Append text at the end of each lineo
~ Jump to the other end of the selectiongv
~ Reselect last visual selectiong CTRL v
~ Increment each line numerically (e.g.,0 0 0 0
~1 2 3 4
)
Window Management #
CTRL wx
~ Swap windowsCTRL wv
~ Split verticallyCTRL ws
~ Split horizontallyCTRL wq
~ Quit windowCTRL w=
~ Equalize window sizes
Useful Operators & Motions #
vap
~ Select around paragraph[{
,]{
,[(
,](
~ Move to last/next unmatched{
,(
g;
~ Jump to previous insert locationg,
~ Jump to next insert location''
~ Jump to before last jump
Command-line Mode Tricks #
CTRL r+
~ Paste from system clipboardCTRL u
~ Delete all charactersCTRL g
/CTRL t
~ Next/previous match in search results:%norm
~ Apply a command to every line (:%norm $ciwhello
):g/^#/d
~ Delete all comments from a Bash file:g/foo/s/bar/baz/g
~ Replace “bar” with “baz” in lines containing “foo”g&
~ Repeat last substitution
Clipboard & Registers #
gx
~ Open link under cursorgf
~ Open file under cursor- If
unnamedplus
is set, copying with system clipboard (CTRL c
) won’t overwrite Vim’s yank buffer.
Miscellaneous #
CTRL g
~ Show filename and line countzz
,zt
,zb
~ Center cursor on screen (middle, top, bottom):center
~ Center textga
~ Show character info under cursorg?
~ ROT13 encode inputCTRL a
/CTRL x
~ Increment/decrement number under cursor:sort u
~ Sort lines uniquely:sort n
~ Sort numerically<C-f>
~ Edit Ex command in a full-page view_
instead of^
~_
moves to the first character on a line but also accepts a motion