# Neovim - The Vim Ecosystem Understanding the relationship between Vim, Neovim, and LazyVim is essential before diving into workflows. They're not competing tools—they're layers building on each other. ## The Family Tree ``` Vi (1976) └─ Vim (1991) - "Vi IMproved" └─ Neovim (2014) - Modern architecture, Lua support └─ LazyVim (2022) - Pre-configured Neovim distribution ``` ## What is Vim? **Vim** (Vi IMproved) is a text editor that pioneered **modal editing**: - **Normal mode:** Navigate and manipulate text (default mode) - **Insert mode:** Type text like a normal editor - **Visual mode:** Select text - **Command mode:** Run ex commands (`:w`, `:q`, etc.) **The core insight:** Separate navigation from insertion. This makes editing extremely fast once you learn it. **Example workflow:** ``` # You want to change "hello world" to "hello universe" # Normal mode: /world # Search for "world" cw # Change word universe # Type new word <Esc> # Back to normal mode ``` **In a regular editor:** - Mouse to "world" - Double-click to select - Type "universe" **In Vim:** - `/world` + `cw` + `universe` + `<Esc>` - No mouse, no repetitive keypresses ## What is Neovim? **Neovim** is a fork of Vim with modern improvements: ### Key Differences from Vim | Feature | Vim | Neovim | |---------|-----|--------| | **Scripting** | VimScript only | Lua + VimScript | | **Built-in LSP** | ❌ (needs plugins) | ✅ Native | | **Treesitter** | ❌ | ✅ Built-in | | **Async** | Limited | Full async I/O | | **API** | Limited | Rich Lua API | | **Defaults** | Conservative (backwards compatible) | Modern | | **Configuration** | `~/.vimrc` | `~/.config/nvim/init.lua` | ### Why Neovim Matters **1. Lua Configuration** ```lua -- Neovim config (Lua) - clean, fast vim.opt.number = true vim.opt.relativenumber = true vim.keymap.set('n', '<leader>w', ':w<CR>') ``` vs ```vim " Vim config (VimScript) - verbose, slower set number set relativenumber nnoremap <leader>w :w<CR> ``` **2. LSP (Language Server Protocol)** Neovim has built-in LSP support: - Autocomplete - Go to definition - Find references - Rename symbols - Code actions **3. Treesitter (Better Syntax)** - Faster syntax highlighting - Better code understanding - Intelligent text objects - Incremental parsing **4. Modern Plugin Ecosystem** - lazy.nvim - Fast plugin manager - Telescope - Fuzzy finder - nvim-cmp - Completion engine - Which-key - Keybinding hints ## What is LazyVim? **LazyVim** is a **Neovim distribution** - a pre-configured setup with: - ✅ Plugin manager (lazy.nvim) configured - ✅ LSP servers for popular languages - ✅ Treesitter parsers installed - ✅ Modern keybindings - ✅ File explorer, fuzzy finder, git integration - ✅ Beautiful UI out of the box **Analogy:** - Neovim = Linux kernel - LazyVim = Ubuntu (pre-configured, batteries included) ### Why Use LazyVim vs Raw Neovim? **Raw Neovim:** - Complete control - Configure everything yourself - Weeks/months to get "IDE-like" - You learn every detail **LazyVim:** - Works immediately - Sane defaults - Easy customization on top - Focus on editing, not config **Recommendation:** Start with LazyVim. Customize later as you understand what you need. ## Modal Editing - The Core Concept This is what makes Vim/Neovim different from **every other editor**. ### The Modes **Normal Mode** (default) - Navigate: `h` `j` `k` `l` (left, down, up, right) - Edit: `d` (delete), `c` (change), `y` (yank/copy) - Search: `/` (forward), `?` (backward) **Insert Mode** (like a normal editor) - Press `i` to enter - Press `<Esc>` to exit back to normal **Visual Mode** (select text) - `v` - character selection - `V` - line selection - `Ctrl+V` - block selection **Command Mode** (run ex commands) - `:w` - write (save) - `:q` - quit - `:wq` - write and quit - `:!` - run shell command ### Why Modal Editing is Powerful **Example: Delete 3 words** **Regular editor:** - Shift+→ → → → → → (hold and hope you selected right amount) - Delete **Vim:** - `d3w` (delete 3 words) - 3 keypresses, precise, no mouse **Example: Change text inside quotes** **Regular editor:** - Click inside quotes - Select carefully - Type new text **Vim:** - `ci"` (change inside quotes) - Type new text - `<Esc>` **Example: Delete everything inside function parentheses** **Regular editor:** - Click and drag to select - Hope you didn't miss anything - Delete **Vim:** - `di(` (delete inside parentheses) - Done ## The Operator-Motion Model Vim commands follow a grammar: ``` [operator][count][motion] ``` **Operators:** - `d` - delete - `c` - change - `y` - yank (copy) - `>` - indent - `<` - outdent **Motions:** - `w` - word - `b` - back word - `
- end of line - `0` - start of line - `}` - paragraph - `i(` - inside parentheses - `a"` - around quotes **Examples:** - `d3w` - delete 3 words - `c
- change to end of line - `y5j` - yank 5 lines down - `>2}` - indent 2 paragraphs - `di{` - delete inside braces - `ca"` - change around quotes **This is why Vim feels like a language.** Once you learn the grammar, you can combine operators and motions infinitely. ## How They Work Together in Your Workflow **Layer 4 of the [[Dev Environment Stack]]:** ``` You press: Cmd+T (Ghostty - Layer 1) ↓ Opens: New terminal tab ↓ Runs: tmux attach (tmux - Layer 2) ↓ Shell: zsh with your config (zsh - Layer 3) ↓ You type: nvim . ↓ Opens: LazyVim (Neovim - Layer 4) ``` **Inside LazyVim:** - Press `Space` → Which-key menu shows available commands - Press `Space f f` → Telescope fuzzy finds files - Navigate with `j`/`k`, select with `Enter` - Edit file with Vim motions - LSP provides autocomplete, errors, etc. - Git integration shows changes inline - Terminal accessible with `Ctrl+\` ## Learning Path **Week 1: Survive** - `h` `j` `k` `l` - navigation - `i` - insert mode - `<Esc>` - back to normal - `:w` - save - `:q` - quit - `dd` - delete line - `u` - undo **Week 2: Basic Editing** - `w` `b` - word navigation - `d` `c` `y` - operators - `p` - paste - `/` - search - `.` - repeat last action **Week 3: Text Objects** - `ciw` - change in word - `di(` - delete inside parentheses - `ca"` - change around quotes - `>i}` - indent inside braces **Week 4: LazyVim Features** - `Space f f` - find files - `Space s g` - search grep - `Space e` - file explorer - `gd` - go to definition - `gr` - go to references **Month 2+: Customization** - Add your own keybindings - Install specific plugins - Configure LSP servers - Build muscle memory ## Common Misconceptions **"Vim is hard to learn"** → The basics take a weekend. Mastery takes months. But you're productive after week 1. **"I need to memorize hundreds of commands"** → You need maybe 20 commands to start. The rest you learn as needed. **"Modal editing is inefficient"** → It's slower for the first week. Then it's 3-5× faster than mouse-based editing. **"LazyVim is for advanced users"** → It's actually **better for beginners** than raw Neovim because it just works. **"I can't use my mouse"** → LazyVim has mouse support enabled. Use it while learning, gradually rely on it less. **"I need to configure everything"** → LazyVim works great out of the box. Customize only what you want. ## Why Learn Neovim in 2025? **1. Speed** - No waiting for VS Code to index - Works on remote servers over slow SSH - 10MB RAM vs 1GB for VS Code **2. Everywhere** - On every server (vi/vim is always installed) - SSH-friendly - Works in tmux, in a container, anywhere **3. Efficiency** - Modal editing is objectively faster once learned - Never take hands off keyboard - Composable commands (operator + motion) **4. Customization** - Full control via Lua - Thousands of plugins - Make it exactly what you want **5. Career Longevity** - Vim is 30+ years old, still going strong - Skills transfer across systems - One-time investment, lifetime benefit ## Next Steps **Get Started:** 1. Install Neovim: `brew install neovim` 2. Install LazyVim: Follow [[LazyVim Setup]] 3. Run `nvim` and go through the tutorial: `:Tutor` **Learn Workflows:** - [[LazyVim Workflows/File Navigation in LazyVim]] - Finding and opening files - [[LazyVim Workflows/Code Editing Workflows]] - Efficient editing patterns - [[LazyVim Workflows/Git Integration in LazyVim]] - Using git inside editor - [[LazyVim Workflows/LSP and Code Intelligence]] - Autocomplete, go to def, etc. **Integrate with Stack:** - [[Dev Environment Stack]] - How Neovim fits into the bigger picture - [[tmux - Terminal Multiplexer]] - Running Neovim in tmux panes - [[Terminal Keyboard Shortcuts]] - Shell editing vs Vim editing **Remember:** LazyVim is just Neovim with a great config. Everything you learn applies to any Neovim setup.