DEV Community

Kamolsit Mongkolsrisawat
Kamolsit Mongkolsrisawat

Posted on

nvim cheatsheet

cheatsheet for Neovim, a popular Vim-based text editor:

Navigation

h, j, k, l: move cursor left, down, up, right
w: move cursor to the start of the next word
b: move cursor to the start of the previous word
e: move cursor to the end of the current word
gg: move cursor to the beginning of the document
G: move cursor to the end of the document
0: move cursor to the beginning of the current line
$: move cursor to the end of the current line
Ctrl-u: move cursor up by half a page
Ctrl-d: move cursor down by half a page
Ctrl-b: move cursor up by a full page
Ctrl-f: move cursor down by a full page

Editing

i: enter insert mode at the cursor position
a: enter insert mode after the cursor position
I: enter insert mode at the beginning of the current line
A: enter insert mode at the end of the current line
o: enter insert mode on a new line below the current line
O: enter insert mode on a new line above the current line
dd: delete the current line
dw: delete from the cursor position to the end of the current word
d$: delete from the cursor position to the end of the current line
yy: yank (copy) the current line
yw: yank from the cursor position to the end of the current word
y$: yank from the cursor position to the end of the current line
p: paste the last yanked or deleted text after the cursor position
P: paste the last yanked or deleted text before the cursor position

Search and Replace

/[pattern]: search forward for the next occurrence of "pattern"
?[pattern]: search backward for the previous occurrence of "pattern"
n: repeat the last search in the same direction
N: repeat the last search in the opposite direction
:%s/old/new/g: replace all occurrences of "old" with "new" in the entire document
:s/old/new/g: replace all occurrences of "old" with "new" in the current line
:s/old/new/gc: replace all occurrences of "old" with "new" in the current line with confirmation prompts

Files and Buffers

:e [filename]: open a file named "filename"
:w: save the current file
:w [filename]: save the current file with a new name "filename"
:q: quit the current buffer
:q!: quit the current buffer without saving changes
:wq: save the current file and quit the buffer
:e#: switch to the Navigationprevious buffer

Miscellaneous

:set [number]: display line numbers
:set [nonumber]: hide line numbers
:set paste: enable paste mode (useful for pasting code without auto-indentation)
:set nopaste: disable paste mode
:set spell: enable spell checking
:set nospell: disable spell checking
:set ignorecase: ignore case when searching
:set noignorecase: do not ignore case when searching
:set hlsearch: highlight search results
:set nohlsearch:

Top comments (1)

Collapse
 
schlich profile image
Tyler Schlichenmeyer

Thanks, I love that this is in a responsive html/css format so i can pin it to my browser sidebar while i work