Cheatsheet Neovim
Editor modal baseado em Vim, extensível em Lua
Neovim
Modes
Insert mode (before)
i
Inserts text before the cursor.
Visual mode
v (characters)
V (lines)
Ctrl + v (block/column)
Selects text in various ways.
Insert mode (after)
a
Inserts text after the cursor.
Command mode
:
Opens the command line.
Insert on the line
I (start of line)
A (end of line)
Inserts at the start or end of the line.
Replace mode
R
Replaces characters the you type.
Back to Normal
Esc (or Ctrl + [)
Exits the current mode to Normal.
Movement
Basic movement
h ← j ↓ k ↑ l →
Moves the cursor without using the arrows.
Half page
Ctrl + d (down)
Ctrl + u (up)
Scrolls half a page.
Word by word
w (next word)
b (previous word)
e (end of word)
Jumps between words.
Full page
Ctrl + f (down)
Ctrl + b (up)
Scrolls one page.
Start / end of line
0 (start)
$ (end)
^ (first character)
Moves within the line.
Matching bracket
%
Jumps to the matching bracket/brace.
Start / end of file
gg (top)
G (end)
Jumps to the start or end.
Go to line
5G (or :5)
Jumps to line 5.
Editing and Operators
Delete character
x
Removes the character under the cursor.
Copy (yank)
yy (line)
yw (word)
Copies text.
Change
cc (line)
cw (word)
Deletes and enters Insert mode.
Delete line
dd
Removes the current line.
Paste
p (after the cursor)
P (before the cursor)
Pastes the copied text.
Replace character
r
Swaps a single character.
Delete to end
D (or d$)
Deletes from the cursor to the end of the line.
Undo / Redo
u (undo)
Ctrl + r (redo)
Reverts or reapplies actions.
Delete word
dw
Deletes the current word.
Repeat action
.
Repeats the last change.
Text Objects
Repeat with number
5dd (deletes 5 lines)
3yw (copies 3 words)
Prefixes an operator with a number.
Delete paragraph
dap
Deletes the whole paragraph.
Inner word
ciw
Changes the word under the cursor.
Delete HTML tag
dat
Deletes the HTML tag and its content.
Inside quotes
ci" (double quotes)
ci' (single quotes)
Changes the text inside the quotes.
Inside brackets
ci( (or cib)
Changes the content between brackets.
Search and Replace
Search forward
/text
Searches for "text" forward.
Replace in the line
:s/old/new/g
Replaces on the current line.
Search backward
?text
Searches for "text" backward.
Replace in everything
:%s/old/new/g
Replaces across the whole file.
Next / previous
n (next)
N (previous)
Navigates through the results.
Clear highlight
:noh
Removes the search highlight.
Word under the cursor
* (forward)
# (backward)
Searches for the current word.
Files and Buffers
Save
:w
Saves the file.
Open file
:e filename
Opens a file in the current buffer.
Quit
:q
Quits (if there are no changes).
Next / previous buffer
:bn (next)
:bp (previous)
Navigates between buffers.
Save and quit
:wq (or :x or ZZ)
Saves and closes.
Close buffer
:bd
Closes the current buffer.
Quit without saving
:q!
Closes discarding changes.
Buffer list
:ls
Shows the open buffers.
Windows and Tabs
Horizontal split
Ctrl + w, s
Splits the window horizontally.
New tab
:tabnew
Opens a new tab.
Vertical split
Ctrl + w, v
Splits the window vertically.
Next / previous tab
gt (next)
gT (previous)
Navigates between tabs.
Move between windows
Ctrl + w, h/j/k/l
Jumps to the left/down/up/right window.
Close window
Ctrl + w, c
Closes the current window.
Command Line
Show line numbers
:set number
Enables line numbering.
Reload configuration
:source $MYVIMRC
Reloads the init.lua/.vimrc.
Hide numbers
:set nonumber
Disables numbering.
Help
:help topic
Opens the documentation about a topic.
Delete everything
:%d
Clears all the file content.
Run shell command
:!command
Runs a system command.