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

  1. Getting Started
  2. Basic Vim Motions
  3. Essential Editing Commands
  4. AstroNvim Specific Features
  5. File Management
  6. Editing Workflows
  7. Terminal Integration
  8. Git Integration
  9. Daily Coding Workflow
  10. 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 mode
  • Esc - Return to Normal mode
  • v - Enter Visual mode
  • : - Enter Command mode

Basic Vim Motions

Character Movement

  • h - Move left
  • j - Move down
  • k - Move up
  • l - Move right

Word Movement

  • w - Move to beginning of next word
  • e - Move to end of current word
  • b - Move to beginning of previous word
  • W, 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 line
  • gg - Go to first line
  • G - Go to last line
  • {number}G - Go to specific line number

Screen Movement

  • H - Move to top of screen
  • M - Move to middle of screen
  • L - Move to bottom of screen
  • Ctrl+u - Scroll up half screen
  • Ctrl+d - Scroll down half screen
  • Ctrl+f - Scroll down full screen
  • Ctrl+b - Scroll up full screen

Search Movement

  • /text - Search forward for β€œtext”
  • ?text - Search backward for β€œtext”
  • n - Next search result
  • N - Previous search result
  • * - Search for word under cursor
  • # - Search backward for word under cursor

Essential Editing Commands

Basic Editing

  • i - Insert before cursor
  • a - Insert after cursor
  • o - Open new line below
  • O - Open new line above
  • x - Delete character under cursor
  • r - Replace character under cursor
  • s - Delete character and enter insert mode

Delete Commands

  • dd - Delete entire line
  • dw - Delete word
  • d$ - Delete to end of line
  • d0 - Delete to beginning of line
  • {number}dd - Delete multiple lines

Copy and Paste

  • yy - Copy (yank) line
  • yw - Copy word
  • y$ - Copy to end of line
  • p - Paste after cursor
  • P - Paste before cursor

Undo and Redo

  • u - Undo
  • Ctrl+r - Redo
  • U - 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/folder
    • a - Add file/folder
    • d - Delete
    • r - Rename
    • c - Copy
    • x - 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 definition
  • gD - Go to declaration
  • gr - Go to references
  • gi - Go to implementation
  • K - 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 fold
  • zc - Close fold
  • zo - Open fold
  • zR - Open all folds
  • zM - Close all folds

Editing Workflows

Text Objects

Text objects allow you to operate on logical units of text:

  • iw - Inner word
  • aw - A word (including space)
  • is - Inner sentence
  • as - A sentence
  • ip - Inner paragraph
  • ap - A paragraph
  • i" - Inner quotes
  • a" - A quotes (including quotes)
  • i) - Inner parentheses
  • a) - A parentheses (including parentheses)

Combining Commands

  • diw - Delete inner word
  • ciw - Change inner word
  • yi) - Yank inner parentheses
  • ca" - Change a quotes
  • dap - Delete a paragraph

Visual Selection

  • v - Character-wise visual selection
  • V - Line-wise visual selection
  • Ctrl+v - Block visual selection
  • gv - Reselect last visual selection

Multiple Cursors

  • <Leader>m - Start multiple cursor mode
  • Ctrl+n - Select next occurrence
  • Ctrl+x - Skip occurrence
  • Ctrl+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

  1. cd to your project directory
  2. Run nvim or nvim . to open the project
  3. Use <Leader>e to open file explorer
  4. Use <Leader>ff to quickly find files

Typical Editing Session

  1. Find files: <Leader>ff
  2. Navigate code: Use gd to go to definitions
  3. Search across files: <Leader>fw to find text
  4. Edit multiple files: Use buffers with ]b and [b
  5. Format code: <Leader>lf
  6. Git operations: <Leader>gg for LazyGit
  7. Terminal: <Leader>tf for floating terminal

Code Review Workflow

  1. <Leader>gg - Open LazyGit
  2. Navigate to commit/branch
  3. <Leader>gp - Preview changes
  4. Use ]g and [g to navigate hunks
  5. <Leader>gc - View commits

Debugging Workflow

  1. <Leader>ld - Show diagnostics
  2. ]d and [d - Navigate between errors
  3. K - Show documentation
  4. <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 quotes
  • da( - Delete around parentheses
  • yap - Yank a paragraph
  • <Leader>ff then type filename - Quick file opening
  • /<search> then cgn - 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

  1. Try navigating a file using only hjkl
  2. Practice text objects: ciw, dap, yi)
  3. Use visual mode to select and manipulate text
  4. Practice search and replace with / and cgn
  5. Try recording and replaying macros