Neovim πΉ
- Neovim is a free and open-source text editor designed as a modern, extensible refinement of Vim (Vi IMproved). Built with performance and developer productivity in mind, Neovim offers a lightweight, modal editing experience that is both highly configurable and exceptionally fast.
- Currently, Iβm using astronvim, a feature-rich and community-driven Neovim configuration that provides a preconfigured, out-of-the-box development environment powered by modern plugins and Lua-based configuration. I am currently using .
- Some Preconfigured Neovim Distributions:
Table of Contents
- Getting Started
- Basic Vim Motions
- Essential Editing Commands
- AstroNvim Specific Features
- File Management
- Editing Workflows
- Terminal Integration
- Git Integration
- Daily Coding Workflow
- Tips and Tricks
Getting Started
Modes in Neovim
Neovim has different modes for different tasks:
- Normal Mode: Navigation and commands (default mode)
- Insert Mode: Text editing
- Visual Mode: Text selection
- Command Mode: Execute commands
Mode Switching
i
- Enter Insert modeEsc
- Return to Normal modev
- Enter Visual mode:
- Enter Command mode
Basic Vim Motions
Character Movement
h
- Move leftj
- Move downk
- Move upl
- Move right
Word Movement
w
- Move to beginning of next worde
- Move to end of current wordb
- Move to beginning of previous wordW
,E
,B
- Same as above but ignore punctuation
Line Movement
0
- Move to beginning of line^
- Move to first non-blank character$
- Move to end of linegg
- Go to first lineG
- Go to last line{number}G
- Go to specific line number
Screen Movement
H
- Move to top of screenM
- Move to middle of screenL
- Move to bottom of screenCtrl+u
- Scroll up half screenCtrl+d
- Scroll down half screenCtrl+f
- Scroll down full screenCtrl+b
- Scroll up full screen
Search Movement
/text
- Search forward for βtextβ?text
- Search backward for βtextβn
- Next search resultN
- Previous search result*
- Search for word under cursor#
- Search backward for word under cursor
Essential Editing Commands
Basic Editing
i
- Insert before cursora
- Insert after cursoro
- Open new line belowO
- Open new line abovex
- Delete character under cursorr
- Replace character under cursors
- Delete character and enter insert mode
Delete Commands
dd
- Delete entire linedw
- Delete wordd$
- Delete to end of lined0
- Delete to beginning of line{number}dd
- Delete multiple lines
Copy and Paste
yy
- Copy (yank) lineyw
- Copy wordy$
- Copy to end of linep
- Paste after cursorP
- Paste before cursor
Undo and Redo
u
- UndoCtrl+r
- RedoU
- Undo all changes on line
AstroNvim Specific Features
File Explorer
<Leader>e
- Toggle file explorer (Neo-tree)<Leader>o
- Focus file explorer- In Neo-tree:
Enter
- Open file/foldera
- Add file/folderd
- Deleter
- Renamec
- Copyx
- Cut
Fuzzy Finding
<Leader>ff
- Find files<Leader>fw
- Find word in files<Leader>fb
- Find buffers<Leader>fh
- Find help tags<Leader>fm
- Find marks<Leader>fo
- Find old files<Leader>fc
- Find commands
Buffer Management
<Leader>c
- Close buffer<Leader>C
- Close all buffers except current]b
- Next buffer[b
- Previous buffer<Leader>bb
- List buffers
Tab Management
<Leader>tn
- New tab<Leader>tc
- Close tab]t
- Next tab[t
- Previous tab
File Management
Opening Files
:e filename
- Open file:sp filename
- Open file in horizontal split:vsp filename
- Open file in vertical split<Leader>ff
- Use fuzzy finder to open files
Saving Files
:w
- Save file:wa
- Save all files:w filename
- Save as filename<Leader>w
- Save (AstroNvim shortcut)
Window Management
<Leader>|
- Vertical split<Leader>-
- Horizontal split<Ctrl+h>
- Move to left window<Ctrl+j>
- Move to down window<Ctrl+k>
- Move to up window<Ctrl+l>
- Move to right window<Ctrl+w>q
- Close current window<Ctrl+w>o
- Close all windows except current
Code Navigation
Language Server Protocol (LSP)
gd
- Go to definitiongD
- Go to declarationgr
- Go to referencesgi
- Go to implementationK
- Show documentation<Leader>lf
- Format code<Leader>la
- Code actions<Leader>lr
- Rename symbol<Leader>ls
- Show symbols
Diagnostics
]d
- Next diagnostic[d
- Previous diagnostic<Leader>ld
- Show line diagnostics<Leader>lD
- Show all diagnostics
Folding
za
- Toggle foldzc
- Close foldzo
- Open foldzR
- Open all foldszM
- Close all folds
Editing Workflows
Text Objects
Text objects allow you to operate on logical units of text:
iw
- Inner wordaw
- A word (including space)is
- Inner sentenceas
- A sentenceip
- Inner paragraphap
- A paragraphi"
- Inner quotesa"
- A quotes (including quotes)i)
- Inner parenthesesa)
- A parentheses (including parentheses)
Combining Commands
diw
- Delete inner wordciw
- Change inner wordyi)
- Yank inner parenthesesca"
- Change a quotesdap
- Delete a paragraph
Visual Selection
v
- Character-wise visual selectionV
- Line-wise visual selectionCtrl+v
- Block visual selectiongv
- Reselect last visual selection
Multiple Cursors
<Leader>m
- Start multiple cursor modeCtrl+n
- Select next occurrenceCtrl+x
- Skip occurrenceCtrl+p
- Previous occurrence
Terminal Integration
Built-in Terminal
<Leader>tf
- Floating terminal<Leader>th
- Horizontal terminal<Leader>tv
- Vertical terminal<C-\><C-n>
- Exit terminal mode<Leader>tl
- Lazy git terminal
Terminal Commands
:terminal
- Open terminal in current window:split | terminal
- Open terminal in horizontal split:vsplit | terminal
- Open terminal in vertical split
Git Integration
Git Commands (with LazyGit)
<Leader>gg
- Open LazyGit<Leader>gl
- Git log<Leader>gs
- Git status<Leader>gb
- Git branches<Leader>gc
- Git commits
Git Signs
]g
- Next git hunk[g
- Previous git hunk<Leader>gp
- Preview git hunk<Leader>gs
- Stage git hunk<Leader>gr
- Reset git hunk<Leader>gu
- Undo stage hunk
Daily Coding Workflow
Opening a Project
cd
to your project directory- Run
nvim
ornvim .
to open the project - Use
<Leader>e
to open file explorer - Use
<Leader>ff
to quickly find files
Typical Editing Session
- Find files:
<Leader>ff
- Navigate code: Use
gd
to go to definitions - Search across files:
<Leader>fw
to find text - Edit multiple files: Use buffers with
]b
and[b
- Format code:
<Leader>lf
- Git operations:
<Leader>gg
for LazyGit - Terminal:
<Leader>tf
for floating terminal
Code Review Workflow
<Leader>gg
- Open LazyGit- Navigate to commit/branch
<Leader>gp
- Preview changes- Use
]g
and[g
to navigate hunks <Leader>gc
- View commits
Debugging Workflow
<Leader>ld
- Show diagnostics]d
and[d
- Navigate between errorsK
- Show documentation<Leader>la
- Code actions to fix issues
Tips and Tricks
Speed Up Your Workflow
- Use
.
to repeat last command - Use
<number><command>
to repeat commands (e.g.,5j
moves down 5 lines) - Use
<Leader>
key combinations extensively - Learn text objects for faster editing
- Use macros:
q<letter>
to start recording,q
to stop,@<letter>
to replay
Common Patterns
ci"
- Change inside quotesda(
- Delete around parenthesesyap
- Yank a paragraph<Leader>ff
then type filename - Quick file opening/<search>
thencgn
- Search and replace workflow
Productivity Shortcuts
<Leader>w
- Quick save<Leader>q
- Quick quit<Leader>h
- Clear search highlights<Leader>c
- Close buffer<Leader>bD
- Close all buffers except current
Learning Resources
:Tutor
- Built-in Neovim tutor:help
- Extensive help system:help <command>
- Help for specific commands:checkhealth
- Check your Neovim setup
Practice Exercises
- Try navigating a file using only
hjkl
- Practice text objects:
ciw
,dap
,yi)
- Use visual mode to select and manipulate text
- Practice search and replace with
/
andcgn
- Try recording and replaying macros