This guide puts installation, configuration and shortcuts for Neovim and NERDTree —the most widely used tree-style file explorer in the Vim ecosystem— in one place, built for working on and supervising AI agents without leaving the terminal. It’s written step by step, so someone who has never opened the editor can follow it just the same.
Don’t try to memorize it. The idea is that you bookmark it or print it, and come back to it whenever you forget a shortcut — that’s what it’s for.
More importantly: every shortcut was tested in a real terminal with Neovim 0.12.6 and the latest NERDTree from GitHub, sending the keys one at a time. If something here doesn’t work for you, the culprit is most likely your terminal or your configuration, not the shortcut. I cover the cases I ran into at the end.
Why this matters right now
If what matters is defining agents, running them immediately, and having visual access to their log traces without leaving the place where you’re already writing, a full IDE can be more weight than the job calls for. The alternative is a terminal and a text editor with steroids: Neovim, with NERDTree as the file explorer. Nothing to load, nothing to wait for, everything one keystroke away.
But choosing to work this way —inside the console, rather than outside it— also has a second reason, less practical and more personal. Today a good share of writing code gets handed off to agents, and I suspect that leaves some sadness and boredom in those of us who were writing it line by line until recently (it would be worth someone actually studying the psychology and feelings of programmers around this). This workflow —terminal, Neovim, NERDTree— wasn’t invented now: it’s been around for a long time. For those who miss programming by hand, this tutorial is for you.
This guide is the starting point for both paths: mastering the editor before asking it to carry a define → run → watch-agent-logs loop, or simply for the pleasure of writing real code again.
Installation
Before the shortcuts, here’s what you need installed. This was tested on Linux; on macOS only the install commands change — the paths and the configuration files are the same.
About paths with
~. Throughout this guide you’ll see paths like~/.config/nvim/init.vim. The~is a shortcut your shell —bash or zsh, the most common ones on Linux and macOS— expands to your user’s home directory. If you use a different shell, or just want to be sure, replace it with the full path: for example/home/your-user/.config/nvim/init.vimon Linux or/Users/your-user/.config/nvim/init.vimon macOS.
-
Neovim 0.11 or newer. The LSP combinations (
Ctrl + ],g, thenr, thenr, andShift + K) andvim.lsp.configneed at least that version. This was tested with 0.12.6. Check yours withnvim --version. On macOS:brew install neovim. On Linux, downloadnvim-linux-x86_64.tar.gzfrom Neovim’s GitHub releases, unpack it, and putbin/nvimon yourPATH—aptpackages are usually old. -
NERDTree. Installed with Neovim’s own native package system, no plugin manager required:
mkdir -p ~/.local/share/nvim/site/pack/vendor/start git clone --depth 1 https://github.com/preservim/nerdtree ~/.local/share/nvim/site/pack/vendor/start/nerdtreeTo check it, type
:NERDTreeand press Enter: the tree should open. -
A language server, if you want to jump to definitions, see references and rename. For Python that’s
pyright, which needs Node.js:npm install -g pyrightTo check it, run
which pyright-langserverin the terminal. -
The system clipboard (optional).
set clipboard=unnamedplusonly works if a clipboard program is installed:xclipon Linux with X11,wl-clipboardon Linux with Wayland, or nothing on macOS (it’s already built in). To check it::checkhealth provider.
With that installed, you’re ready for the rest of the guide. Further down, in “Custom shortcuts”, we build the full ~/.config/nvim/init.vim that enables the LSP and the window shortcuts.
How to read this guide
The instructions follow a strict convention:
| If the guide says… | It means… |
|---|---|
| Press Ctrl + w | Hold down Ctrl and, without releasing it, press w. Then release both. |
| Press Ctrl + w, release, then press h | That’s TWO steps. First Ctrl + w (together), release everything, then press just h, without Ctrl. |
| Press g, then g | Press the g key twice in a row, quickly. |
| Press Shift + g | That’s capital G. |
Type :w and press Enter |
Type the colon, then w, and confirm with Enter. What you type appears at the bottom, on the last line of the screen. |
| Escape | The Esc key. Use it whenever you’re not sure which mode you’re in: it takes you back to Normal mode. |
Unless stated otherwise, every shortcut is used in Normal mode. If pressing a key types it into the file, you’re in Insert mode: press Escape and try again.
Everything works with no configuration, except the “Custom shortcuts” section, which requires copying a configuration into your ~/.config/nvim/init.vim (see “Installation” if you don’t have Neovim, NERDTree or pyright installed yet).
If you only remember seven things
Before the full reference, the minimum to avoid getting stuck. Remember: every time you type : (colon), what you type doesn’t show up where the cursor is — it shows up at the bottom, on the last line of the screen.
- Escape takes you back to Normal mode. When in doubt, Escape.
- i to start typing.
:wand Enter to save.:q!and Enter to quit without saving (the emergency exit).:NERDTreeToggleand Enter to show or hide the file tree.- Inside the tree, o opens the file or folder under the cursor.
- Ctrl + w, release, then w jumps between the tree and the code.
That’s enough to get work done. Everything else makes you faster.
Part I: Neovim
Modes
Neovim is a modal editor: the same keys do different things depending on the mode. In Normal mode, letters are commands; in Insert mode, they type text.
| What you want to do | How to do it |
|---|---|
| Return to Normal mode | Press Escape |
| Start typing before the cursor | Press i |
| Start typing after the cursor | Press a |
| Start typing at the start of the line | Press Shift + i |
| Start typing at the end of the line | Press Shift + a |
| Create a new line below and type | Press o |
| Create a new line above and type | Press Shift + o |
| Select by characters | Press v |
| Select whole lines | Press Shift + v |
| Select a rectangular block | Press Ctrl + v |
| Type a command | Press : (colon) |
Save and quit
The most-searched question about Vim is how to quit it. Here are all the variants:
| What you want to do | How to do it |
|---|---|
| Save the file | Type :w and press Enter |
| Quit (if there are no unsaved changes) | Type :q and press Enter |
| Save and quit | Type :wq and press Enter |
| Quit without saving (discards changes) | Type :q! and press Enter |
| Save all open files | Type :wa and press Enter |
| Quit everything, only if nothing is unsaved anywhere | Type :qa and press Enter. If anything was left unsaved, Neovim refuses with “E37: No write since last change” and closes nothing — it doesn’t “quit everything” the way it sounds. |
| Save everything and quit everything | Type :wqa and press Enter. If any buffer has no file name (one you never saved), it stops right there with “E32: No file name”; save it with :w name or discard it with :bd! and try again. |
| Quit everything without saving anything, no matter what | Type :qa! and press Enter |
| Open another file by name | Type :e path/to/file and press Enter (Tab autocompletes) |
Moving around the file
The arrow keys work, but h, j, k and l keep your hand from leaving the keyboard. What actually saves time are jumps by word, block and file.
| What you want to do | How to do it |
|---|---|
| Move left | Press h (or the left arrow) |
| Move down | Press j (or the down arrow) |
| Move up | Press k (or the up arrow) |
| Move right | Press l (or the right arrow) |
| Go to the next word | Press w |
| Go to the previous word | Press b |
| Go to the end of the word | Press e |
| Go to the start of the line | Press 0 (zero) |
| Go to the first non-blank character of the line | Press ^ (Shift + 6 on a US keyboard) |
| Go to the end of the line | Press $ (Shift + 4) |
| Go to the start of the file | Press g, then g |
| Go to the end of the file | Press Shift + g |
| Go to line 25 | Type :25 and press Enter |
| Scroll down half a screen | Press Ctrl + d |
| Scroll up half a screen | Press Ctrl + u |
| Jump to the matching parenthesis or brace | Press % (Shift + 5) |
| Jump to the next block or paragraph | Press } |
| Jump to the previous block or paragraph | Press { |
| Go to the next x character on the line | Press f, then x (any character) |
| Center the screen on the cursor | Press z, then z |
| Go back to where you were before a jump | Press Ctrl + o |
| Go to the definition of the variable under the cursor (same file) | Press g, then d |
Editing
This is Vim’s core: commands that combine. d deletes, c changes, y copies, and they combine with an object, like iw (the word) or i" (the text inside quotes).
| What you want to do | How to do it |
|---|---|
| Delete the character under the cursor | Press x |
| Cut the whole line | Press d, then d |
| Cut 5 lines | Press 5, then d, then d |
| Cut from the cursor to the end of the line | Press Shift + d |
| Delete the whole word under the cursor | Press d, then i, then w |
| Copy the whole line | Press y, then y |
| Paste below or after the cursor | Press p |
| Paste above or before the cursor | Press Shift + p |
| Replace the word under the cursor | Press c, then i, then w, then type the new word; finish with Escape |
| Replace the text inside quotes | Press c, then i, then “ and type; finish with Escape |
| Replace the text inside parentheses | Press c, then i, then ( and type; finish with Escape |
| Replace the whole line | Press c, then c, then type; finish with Escape |
| Change a single character | Press r, then the new character |
| Join the line with the one below | Press Shift + j |
| Undo | Press u |
| Redo | Press Ctrl + r |
| Repeat the last change | Press . (dot) |
| Increase the line’s indent | Press >, then > |
| Decrease the line’s indent | Press <, then < |
| Reindent the whole file | Press g, then g, then =, then Shift + g |
System clipboard. To copy or paste between Neovim and other applications, Neovim needs a clipboard program:
xcliporwl-clipboardon Linux (already built in on macOS). To check it, type:checkhealth providerand press Enter. So you don’t have to do it by hand every time, addset clipboard=unnamedplusto your configuration (see “Custom shortcuts”).
Selecting (Visual mode)
| What you want to do | How to do it |
|---|---|
| Select text | Press v and move with h, j, k or l |
| Cut the selection | With text selected, press d |
| Copy the selection | With text selected, press y |
| Replace the selection | With text selected, press c, type, and finish with Escape |
| Increase the selection’s indent | With lines selected, press > |
| Decrease the selection’s indent | With lines selected, press < |
| Type the same thing at the start of several lines | Press Ctrl + v, go down with j, press Shift + i, type the text, press Escape |
| Reselect the last selection | Press g, then v |
Search and replace
| What you want to do | How to do it |
|---|---|
| Search forward | Type /text and press Enter |
| Search backward | Type ?text and press Enter |
| Go to the next match | Press n |
| Go to the previous match | Press Shift + n |
| Search for the word under the cursor | Press * (asterisk) |
| Clear the search highlight | Type :noh and press Enter |
| Replace on the current line | Type :s/old/new/g and press Enter |
| Replace across the whole file | Type :%s/old/new/g and press Enter |
| Replace across the whole file, confirming each one | Type :%s/old/new/gc and press Enter; then y (yes) or n (no) for each case |
Windows: moving between NERDTree and your code
NERDTree is just another window. To enter or leave the tree you use the same shortcuts as for any split window.
| What you want to do | How to do it |
|---|---|
| Go to the left window (the tree) | Press Ctrl + w, release, then press h |
| Go to the right window (the code) | Press Ctrl + w, release, then press l |
| Go to the window below | Press Ctrl + w, release, then press j |
| Go to the window above | Press Ctrl + w, release, then press k |
| Toggle between windows (tree ↔ code) | Press Ctrl + w, release, then press w |
| Go to the tree with a command (always works) | Type :NERDTreeFocus and press Enter |
| Split the screen vertically | Type :vsp and press Enter |
| Split the screen horizontally | Type :sp and press Enter |
| Close the current window | Press Ctrl + w, release, then press q |
| Keep only the current window (closes the rest) | Press Ctrl + w, release, then press o |
| Equalize the size of the windows | Press Ctrl + w, release, then press = |
Buffers (open files) and tabs
| What you want to do | How to do it |
|---|---|
| See the open files | Type :ls and press Enter |
| Go to the next open file | Type :bn and press Enter |
| Go to the previous open file | Type :bp and press Enter |
| Go to an open file by name | Type :b name and press Enter (Tab autocompletes) |
| Close the current file | Type :bd and press Enter |
| Open a new tab | Type :tabnew and press Enter |
| Go to the next tab | Press g, then t |
| Go to the previous tab | Press g, then Shift + t |
| Close the tab | Type :tabclose and press Enter |
Part II: NERDTree
Opening and closing the tree
| What you want to do | How to do it |
|---|---|
| Check that NERDTree is installed | Type :NERDTree and press Enter. If it says “Not an editor command”, the plugin isn’t installed. |
| Open the tree | Type :NERDTree and press Enter |
| Show or hide the tree | Type :NERDTreeToggle and press Enter |
| Go to the tree (opens it if closed) | Type :NERDTreeFocus and press Enter |
| Reveal the file you’re editing in the tree | Type :NERDTreeFind and press Enter |
| Open the tree in another folder | Type :NERDTree /folder/path and press Enter |
| Close the tree (while inside it) | Press q |
| View NERDTree’s help | While in the tree, press ? (press it again to close it) |
A trick: if you open Neovim with nvim . (with a dot), NERDTree opens directly in the current folder.
Opening files and folders
First get inside the tree (see “Windows”) and put the cursor on the file or folder.
| What you want to do | How to do it |
|---|---|
| Open the file (the cursor moves to the file) | Press o (or press Enter) |
| Expand or collapse a folder | Press o (or press Enter) |
| Preview the file without leaving the tree | Press g, then o |
| Open in a window to the right (vertical split) | Press s |
| Open in a vertical split without leaving the tree | Press g, then s |
| Open in a window below (horizontal split) | Press i |
| Open in a horizontal split without leaving the tree | Press g, then i |
| Open in a new tab | Press t |
| Open in a new tab, staying in the current one | Press Shift + t |
| Expand the folder and all its subfolders | Press Shift + o |
| Collapse the folder containing the current item | Press x |
| Collapse all subfolders | Press Shift + x |
Moving around the tree
| What you want to do | How to do it |
|---|---|
| Go down to the next item | Press j |
| Go up to the previous item | Press k |
| Search for a visible file in the tree | Type /name and press Enter |
| Go to the root of the tree | Press Shift + p |
| Go to the folder containing the item | Press p |
| Go to the first item in the current folder | Press Shift + k |
| Go to the last item in the current folder | Press Shift + j |
| Make the selected folder the root | Press Shift + c |
| Move the root up one level (to the parent folder) | Press u |
| Set Neovim’s working directory to the selected folder | Press c, then d |
| Set the tree’s root to the working directory | Press Shift + c, then Shift + d |
| Refresh the selected folder (if you created files outside Neovim) | Press r |
| Refresh the whole tree | Press Shift + r |
Create, rename, copy and delete (the m menu)
Put the cursor on a file or folder in the tree and press m. A menu appears at the bottom; press the letter for the option.
| What you want to do | How to do it (step by step) |
|---|---|
| Create a new file | 1. Cursor on the folder where you want it. 2. Press m, then a. 3. The folder’s path appears at the bottom; type the name at the end (e.g. new.py). 4. Press Enter. |
| Create a new folder | Same as creating a file, but end the name with a slash: myfolder/ and press Enter. |
| Rename or move | 1. Cursor on the file. 2. Press m, then m. 3. The current path appears; erase it with Backspace and type the new path. 4. Press Enter. 5. If the file was open, it asks whether to replace the buffer: press y. |
| Copy | 1. Cursor on the file. 2. Press m, then c. 3. Edit the destination path. 4. Press Enter. |
| Delete a file | 1. Cursor on the file. 2. Press m, then d. 3. It asks “Are you sure…? (yN)”: press y. |
| Delete a folder with contents | Press m, then d. Since the folder isn’t empty, you must type yes and press Enter. |
| View the file’s details (size, permissions) | Press m, then l |
| Copy the path to the clipboard | Press m, then p |
| Cancel the menu | Press Escape |
View, filters and bookmarks
| What you want to do | How to do it |
|---|---|
Show or hide hidden files (the ones starting with a dot, like .env) |
Press Shift + i |
| Show only folders or show files again | Press Shift + f |
| Maximize or restore the tree’s width | Press Shift + a |
| Create a bookmark for the current folder | Type :Bookmark name and press Enter |
| Show or hide the bookmark list | Press Shift + b |
| Open a bookmark | Type :OpenBookmark name and press Enter |
Part III: making it yours
Custom shortcuts
These shortcuts are not built in. You need NERDTree installed and, for the LSP shortcuts, pyright — see “Installation” at the start of the guide. Without the configuration file, Ctrl + h, Ctrl + n or Space followed by e do nothing.
Step 1. Create the folder and open the file from the terminal. The full path is ~/.config/nvim/init.vim:
mkdir -p ~/.config/nvim
nvim ~/.config/nvim/init.vim
Step 2. Press i and paste this:
let mapleader = " "
set number relativenumber
set mouse=a
set clipboard=unnamedplus
" NERDTree
nnoremap <leader>e :NERDTreeToggle<CR>
nnoremap <leader>f :NERDTreeFind<CR>
nnoremap <C-n> :NERDTreeFocus<CR>
let NERDTreeShowHidden = 1
" Quit Neovim if NERDTree is the only window left
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
" Move between windows with Ctrl + h, j, k, l
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Python LSP (go to definition, references, rename)
lua << LUA
vim.lsp.config('pyright', {
cmd = { 'pyright-langserver', '--stdio' },
filetypes = { 'python' },
root_markers = { 'pyproject.toml', 'setup.py', 'requirements.txt', '.git' },
})
vim.lsp.enable('pyright')
LUA
Step 3. Press Escape, type :wq and press Enter. Reopen Neovim.
Step 4 (check). Inside Neovim, type :nmap <C-h> and press Enter. If it says “No mapping found”, the file wasn’t loaded: check that the path is exactly ~/.config/nvim/init.vim and that there isn’t also a ~/.config/nvim/init.lua in that folder. With a .py file open, :checkhealth vim.lsp should list pyright — for that, the project needs one of the root_markers from the “Installation” section, for example a .git folder or a requirements.txt.
| What you want to do (with the configuration) | How to do it |
|---|---|
| Show or hide the tree | Press Space, release, then press e |
| Reveal the current file in the tree | Press Space, release, then press f |
| Go to the tree | Press Ctrl + n |
| Go to the left window (the tree) | Press Ctrl + h |
| Go to the right window (the code) | Press Ctrl + l |
| Go to the window below | Press Ctrl + j |
| Go to the window above | Press Ctrl + k |
| Go to the symbol’s definition (needs pyright) | Press Ctrl + ] |
| See the symbol’s references | Press g, then r, then r |
| Rename the symbol across the project | Press g, then r, then n |
| See the symbol’s type or docs | Press Shift + K |
The last four are what really justifies the jump away from an IDE: jumping to a definition, seeing who calls a function, or renaming it across the whole project without leaving the terminal.
What depends on what, in short:
| Works with no configuration | Needs something installed or configured |
|---|---|
| Ctrl + w, release, then h or l | Ctrl + h or Ctrl + l, Ctrl + n, Space + e or f (~/.config/nvim/init.vim) |
:NERDTreeFocus, :NERDTreeToggle (with NERDTree installed) |
Ctrl + ], g-r-r, g-r-n, Shift + K (pyright + the init.vim lua block) |
NERDTree’s m menu, :!cp …, :e! |
Copying and pasting with other applications (xclip or wl-clipboard) |
A typical workflow
Here’s a full session, start to finish:
- In the terminal, go to your project:
cd my-project - Open Neovim:
nvim - Open the tree: type
:NERDTreeand press Enter (with the configuration: Space, then e). - Move with j and k; press o to open folders and files.
- The file opens on the right and the cursor moves to it. Edit: press i, type, press Escape.
- Save: type
:wand press Enter. - Go back to the tree: press Ctrl + w, release, then h (or type
:NERDTreeFocusand press Enter). - Open another file on the right in a vertical split: press s.
- When you’re done: type
:wqaand press Enter. If Neovim stops with an error instead of closing, some buffer somewhere is unsaved or has no file name — check “Save and quit” in Part I, or force the exit with:qa!if you don’t mind losing those changes.
What testing it taught me
Testing every shortcut for real, one keystroke at a time, uncovered seven traps that almost no guide mentions:
:qadoesn’t always “quit everything” like it promises. If anything, anywhere, is unsaved, Neovim refuses with “E37” and closes nothing.:wqafixes that by saving first, unless some buffer has no file name. To quit with nothing stopping you, the real exit is:qa!.- The LSP needs a root marker, or it never starts.
pyrightonly activates if the project has.git,pyproject.toml,setup.pyorrequirements.txtin some parent directory. A lone.pyfile in an empty folder triggers nothing::checkhealth vim.lspconfirms it. - Your terminal may steal shortcuts. The VS Code integrated terminal and browser-based terminals capture Ctrl + w before it reaches Neovim. If nothing happens, use
:NERDTreeFocusor the custom shortcuts. - Ctrl + h is sometimes Backspace. In some terminals they’re the same signal. If the mapping doesn’t work, go back to Ctrl + w, release, then h.
- The clipboard isn’t automatic. Without
xcliporwl-clipboardon Linux, copying to other applications doesn’t work even withclipboard=unnamedplus. init.vimandinit.luadon’t coexist. If both exist in~/.config/nvim, your~/.config/nvim/init.vimmay not load.:nmaptells you whether your shortcuts are active.- NERDTree’s prompts sit there waiting. While the m menu or a yes/no prompt is open, the next key you press answers it. Escape cancels.
Keep learning
| What you want to do | How to do it |
|---|---|
| Neovim’s interactive tutorial (about 30 minutes, highly recommended) | Type :Tutor and press Enter |
| NERDTree’s full manual | Type :help NERDTree and press Enter |
| Help on a topic | Type :help topic and press Enter (e.g. :help motion) |
| Close the help window | Type :q and press Enter |
| See your active custom shortcuts | Type :nmap and press Enter |
| Diagnose the install | Type :checkhealth and press Enter |
If you only do one thing after reading this, make it :Tutor. Thirty minutes there are worth as much as reading this whole guide.