Neovim Basics
Neovim Basics
Navigation
Jump to Line
gg " Jump to first line (top of file)
G " Jump to last line (bottom of file)
50G " Jump to line 50
:50 " Alternative: go to line 50
1G " Jump to line 1
Screen Navigation
Ctrl-u " Scroll up half a page
Ctrl-d " Scroll down half a page
Ctrl-b " Scroll up a full page (back)
Ctrl-f " Scroll down a full page (forward)
H " Jump to top of screen (High)
M " Jump to middle of screen (Middle)
L " Jump to bottom of screen (Low)
Line Navigation
0 " Jump to start of line
$ " Jump to end of line
^ " Jump to first non-blank character of line
w " Jump to next word
b " Jump back a word
e " Jump to end of word
Other Useful Jumps
% " Jump to matching bracket/paren
{ " Jump to previous paragraph
} " Jump to next paragraph
Buffer Management
Creating Buffers
:enew " Create new empty buffer
:new " Create new buffer in horizontal split
:vnew " Create new buffer in vertical split
Switching Buffers
:bn " Next buffer
:bp " Previous buffer
:b<number> " Go to buffer by number
:b <partial-name> " Go to buffer by name (with tab completion)
:ls " List all buffers
Buffer Symbols
% " Current buffer filename
# " Alternate buffer (previous buffer)
Closing Buffers
:bd " Delete current buffer
:bd <number> " Delete buffer by number
:bw " Wipe buffer (remove from buffer list)
Splits and Windows
Creating Splits
:split " Horizontal split
:vsplit " Vertical split
:sp <file> " Open file in horizontal split
:vsp <file> " Open file in vertical split
Navigating Splits
Ctrl-w h " Move to left split
Ctrl-w j " Move to split below
Ctrl-w k " Move to split above
Ctrl-w l " Move to right split
Ctrl-w w " Cycle through splits
Resizing Splits
Ctrl-w = " Make splits equal size
Ctrl-w > " Increase width
Ctrl-w < " Decrease width
Ctrl-w + " Increase height
Ctrl-w - " Decrease height
Closing Splits
:q " Close current split/window
Ctrl-w q " Close current split
Ctrl-w o " Close all other splits (only keep current)
Tabs
:tabnew " Create new tab
:tabn " Next tab
:tabp " Previous tab
:tabclose " Close current tab
gt " Next tab (normal mode)
gT " Previous tab (normal mode)
3gt " Go to tab 3
File Operations
Opening Files
:e <file> " Edit file
:e . " Open file browser for current directory
:e %:h " Open directory of current file
:E " File explorer (netrw)
Saving Files
:w " Write (save) current file
:w <filename> " Save as new filename
:wa " Write all modified buffers
:wq " Write and quit
:x " Write (if modified) and quit
ZZ " Write and quit (normal mode)
File Info
:f " Show current filename and position
:file " Same as :f
Ctrl-g " Show file info
Visual Mode
Entering Visual Mode
v " Character-wise visual mode
V " Line-wise visual mode
Ctrl-v " Block-wise visual mode
gv " Reselect last visual selection
Visual Mode Operations
d " Delete selection
y " Yank (copy) selection
c " Change selection (delete and enter insert mode)
> " Indent selection
< " Unindent selection
Copy/Paste (Yank/Put)
Basic Yank/Put
yy " Yank (copy) current line
y<motion> " Yank based on motion (e.g., yw = yank word)
p " Put (paste) after cursor
P " Put before cursor
dd " Delete (cut) line
d<motion> " Delete based on motion
System Clipboard
"+y " Yank to system clipboard
"+p " Paste from system clipboard
"*y " Yank to primary selection (Linux)
"*p " Paste from primary selection
Named Registers
"ay " Yank to register 'a'
"ap " Paste from register 'a'
:reg " Show all registers
See Search and Replace for searching and the substitute command.
Undo/Redo
u " Undo
Ctrl-r " Redo
U " Undo all changes on current line
:earlier 10m " Go to state 10 minutes ago
:later 5m " Go forward 5 minutes
:undolist " Show undo tree
Editing
Insert Mode
i " Insert before cursor
a " Insert after cursor
I " Insert at beginning of line
A " Insert at end of line
o " Open new line below
O " Open new line above
Changing Text
cw " Change word
c$ " Change to end of line
cc " Change entire line
r " Replace single character
R " Enter replace mode
Deleting Text
x " Delete character under cursor
X " Delete character before cursor
dw " Delete word
d$ " Delete to end of line
dd " Delete line
Marks
ma " Set mark 'a' at current position
'a " Jump to mark 'a'
:marks " List all marks
Macros
qa " Start recording macro in register 'a'
q " Stop recording
@a " Execute macro 'a'
@@ " Repeat last macro
Command History
: " Enter command mode
:<Up> " Previous command
:<Down> " Next command
:history " Show command history
q: " Open command history window
Help System
:help " Open help
:help <topic> " Help on specific topic
:help :w " Help on :w command
:help buffers " Help on buffers
:help quickref " Quick reference
Ctrl-] " Follow help link
Ctrl-o " Go back
Tips
- Use
.to repeat the last change - Use
Ctrl-oto jump back to previous location - Use
Ctrl-ito jump forward :set numberto show line numbers:set relativenumberfor relative line numberszzto center current line on screen
Tags: #neovim #cli