A list of helpfull commands in nvim
- Always assume we are in normal mode unless explicitely specified
- This guide uses the default commands (no remapping unless explicity specified)
- For a config template: see my nvim config here
:help file
nvim filename1 filename2
open filesfilename1
andfilename2
with nvim
:help normal
ESC
orctrl+[
return to normal mode
:help save-file
:help quit
Note that !
can be appended to the following commands to force it (i.e :wq!
)
:w
write to current file:q
quit file (must be saved before):wq
or:x
write & quit:saveas
save current file into another file
Here are a few equivalent shorthandsZZ
is like:x
ZQ
is like:q!
:help insert
i
enter insert mode
:help replace
r
enter replace mode
:help movement
gg
go to first line of fileG
go to last line of file5G
go to line 5%
go to next part of parenthesis, bracket etc.up
ork
move updown
orj
move downleft
orh
move leftright
ofl
move right
:help undo
u
undo one changeCTRL-R
redo one change:undolist
show the undo list (usefull when undo branching happens)
:help paste
p
paste content of unnnamed register after cursor"aP
paste the content of registera
before cursor
:help yank
yw
yank word forward into unnnamed register"ayW
yank WORD forward into registera
"+yy
yank current line to clipboardy}
yank paragraph into unnnamed register
.
will repeat the previous command if possible
(Concept) Many commands can be executed multiple times by prepending them with any number, which represent the number of repetition we need.5i
will enter insert mode and insert 5 times the content written7dd
wil delete the 7 following lines, including the current one99yy
will yank 99 lines, including the current one- etc.
:help search
/word
to enter forward search mode and searchword
n
while forward searching to go forwardN
while forward searching to go backward*
search current word forward#
search current word backwardsctrl+o
return to previous position before search
:help registers
""
the unnamed (default) register"a
overwrite version of registera
"A
append version of registera
"+
the clipboard"_
the black hole register, does nothing (not affecting the other registers"/
the last used regex register
:help ins-completion
while in insert mode
ctrl+n
any completionctrl+x + ctrl+n
keyword in filectrl+x + ctrl+k
words in dictionaryctrl+x + ctrl+t
words in thesaurusctrl+x + ctrl+f
filenames
qa
will start a recording in overwrite mode in registera
qA
will start a recording in append mode in registera
@a
will execute the recording in regestera
:help formatting
~
swap character between UPPER lowergUw
make word UPPERguw
make word lowergqq
format current linegqap
format current paragraphgqG
format from current line to end of file
:help tags
- ctags must be present in the root directory to allow jumping.
ctrl+]
jump to tag on cursorctrl+t
go to position prior to tag jump
:help jump-motions
ctrl+o
go to previous position in jump listctrl+i
go to next position in jump list:ju
show jump list
:help substitute
:<range>s/<regex_expr>/<replacement>/<flag>
:help range
%
for the whole file.'<,'>
for the lines of visually selected block. This might get you more than you want of the visual selection starts or ends in the middle of a line. The whole line is included.'a,'b
from mark a to mark b..,$
from the current line to the end of the file..,.+10
from current line to 10 lines below current line:help :range
for more
:help regex
:help s_flags
c
ask to confirm before each substitutiong
replace all occurences on the line (as opposed to the first occurence)i
ignorecase for regex patternI
dont ignorecase for regex pattern
:help folding
za
while in a code block to toggle between collapsed / normal
:help block
ctrl+v
enter visual block mode (I remapped to v cuz normal visual mode sucks)
while in visual block modeI
enter block insert mode which will insert before the cursor for every line in blockshift+$
select the whole block from left to rightA
enter block append mode which will append after the cursor for every line in block