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 filename2open filesfilename1andfilename2with nvim
:help normal
ESCorctrl+[return to normal mode
:help save-file
:help quit
Note that ! can be appended to the following commands to force it (i.e :wq!)
:wwrite to current file:qquit file (must be saved before):wqor:xwrite & quit:saveassave current file into another file
Here are a few equivalent shorthandsZZis like:xZQis like:q!
:help insert
ienter insert mode
:help replace
renter replace mode
:help movement
gggo to first line of fileGgo to last line of file5Ggo to line 5%go to next part of parenthesis, bracket etc.uporkmove updownorjmove downleftorhmove leftrightoflmove right
:help undo
uundo one changeCTRL-Rredo one change:undolistshow the undo list (usefull when undo branching happens)
:help paste
ppaste content of unnnamed register after cursor"aPpaste the content of registerabefore cursor
:help yank
ywyank word forward into unnnamed register"ayWyank WORD forward into registera"+yyyank 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.5iwill enter insert mode and insert 5 times the content written7ddwil delete the 7 following lines, including the current one99yywill yank 99 lines, including the current one- etc.
:help search
/wordto enter forward search mode and searchwordnwhile forward searching to go forwardNwhile forward searching to go backward*search current word forward#search current word backwardsctrl+oreturn to previous position before search
:help registers
""the unnamed (default) register"aoverwrite version of registera"Aappend 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+nany completionctrl+x + ctrl+nkeyword in filectrl+x + ctrl+kwords in dictionaryctrl+x + ctrl+twords in thesaurusctrl+x + ctrl+ffilenames
qawill start a recording in overwrite mode in registeraqAwill start a recording in append mode in registera@awill execute the recording in regestera
:help formatting
~swap character between UPPER lowergUwmake word UPPERguwmake word lowergqqformat current linegqapformat current paragraphgqGformat 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+tgo to position prior to tag jump
:help jump-motions
ctrl+ogo to previous position in jump listctrl+igo to next position in jump list:jushow 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,'bfrom mark a to mark b..,$from the current line to the end of the file..,.+10from current line to 10 lines below current line:help :rangefor more
:help regex
:help s_flags
cask to confirm before each substitutiongreplace all occurences on the line (as opposed to the first occurence)iignorecase for regex patternIdont ignorecase for regex pattern
:help folding
zawhile in a code block to toggle between collapsed / normal
:help block
ctrl+venter visual block mode (I remapped to v cuz normal visual mode sucks)
while in visual block modeIenter block insert mode which will insert before the cursor for every line in blockshift+$select the whole block from left to rightAenter block append mode which will append after the cursor for every line in block