Neovim Cheet Sheet
Cập nhật ngày 19/01/2025
Lượt xem: 8
Neovim Command
general information
- in Normal mode is where you run your commands and the quickest path to normal mode is
esc
button
:w
write/save
i
insert mode: to write text or code
esc
to go back to normal mode
q
quit
q!
force quit
:wd
save and quit
Moving around
h
, j
, k
, l
: Move left, down, up, and right respectively.
gg
: Go to the beginning of the file.
G
: Go to the end of the file.
Ctrl + U
: Scroll half-page up.
Ctrl + D
: Scroll half-page down.
Ctrl + B
: Scroll one page up.
Ctrl + F
: Scroll one page down.
Ctrl + E
: Scroll one line down.
Ctrl + Y
: Scroll one line up.
Ctrl + O
: Jump back to the previous location.
Ctrl + I
: Jump forward to the next location.
Editing
i
: Enter insert mode at the current cursor position.
a
: Enter insert mode after the current cursor position.
A
: Enter insert mode at the end of the current line.
o
: Insert a new line below the current line and enter insert mode.
O
: Insert a new line above the current line and enter insert mode.
x
: Delete the character under the cursor.
dd
: Delete the current line.
yy
: Yank (copy) the current line.
p
: Paste the previously yanked or deleted text.
Formatting
=
: Auto-indent the selected lines or the current block.
>
: Increase the indentation of the selected lines or the current line.
<
: Decrease the indentation of the selected lines or the current line.
:1,10 s/^/ /
: Indent lines 1 to 10 with four spaces.
:1,10 s/ //
: Remove four leading spaces from lines 1 to 10.
Searching and replacing
/
: Start a forward search. Type the search pattern and press Enter.
?
: Start a backward search. Type the search pattern and press Enter.
n
: Move to the next occurrence of the search pattern.
N
: Move to the previous occurrence of the search pattern.
:s/search/replace/g
: Replace all occurrences of “search” with “replace” in the current line.
:%s/search/replace/g
: Replace all occurrences of “search” with “replace” in the entire file.