The Basics
Neovim is a modern Vim fork with enhanced features for efficient text editing and coding. I’m a long-time Vim user and switched to Neovim as it enhances my existing workflows. Many of the commands and workflows listed here work in both Vim and Neovim, but look for a vanilla Vim article if you’re using Vim to prevent confusion.
Some of the advantages of using Neovim over Vim are:
- Better plugin architecture including asynchronous plugins, native LSP support, and lua-first configuration.
- Advanced syntax highlighting, including tree-sitter.
- True color support.
- And, most importantly, it has a livlier community.
You can get Neovim from the official website.
Primary Use Cases
- Editing text files with speed and precision
- Writing and maintaining code efficiently
- Managing files and directories
- Navigating your IDE with minimal hand movement through optimal keybindings
Less Suitable Use Cases
- Editing binary files (use specialized tools instead)
- Writing prose (consider dedicated writing tools)
- Navigating the web (use a web browser)
- Running scripts (use a terminal)
- Managing processes (use system monitoring tools)
Command Reference
Window Commands
- :new
filename
- Create a new window (and file if filename provided) - :split - Split the window horizontally
- :vsplit - Split the window vertically
- :q - Close the current window
- Ctrl-w s - Split the window horizontally
- Ctrl-w v - Split the window vertically
- Ctrl-w w - Cycle through all windows
- Ctrl-w q - Close the current window
Tab Commands
- :tabnew - Create a new tab
- :tabnext - Move to the next tab
- :tabprevious - Move to the previous tab
- :tabclose - Close the current tab
- gt - Move to the next tab
- gT - Move to the previous tab
- 1gt - Move to the first tab
- 2gt - Move to the second tab
File Commands
- :! mkdir
directory
- Create a new directory - :! touch
filename
- Create a new file - :edit
filename
- Edit a file - :e
filename
- Edit a file - :write - Save the file
- :w - Save the file
- :x - Save and exit
- :exit - Exit
- :q - Exit
Directory Commands
- nvim . - Open the current directory
- :pwd - Print the current working directory
- :cd
/path/to/directory
- Change the current working directory - :Explore - Open the file explorer
- d - Create a new directory (in Explore)
- % - Create a new file (in Explore)
Editing Commands
File Operations
- dG - Delete to the end of the file
- dd - Delete the current line
Paragraph Operations
- d( - Delete to the end of the current paragraph
- d) - Delete to the beginning of the current paragraph
Block Operations
- d{ - Delete to the end of the current block
- d} - Delete to the beginning of the current block
Sentence Operations
- d[ - Delete to the end of the current sentence
- d] - Delete to the beginning of the current sentence
General Operations
- p - Paste the deleted text after the cursor
- P - Paste the deleted text before the cursor
- u - Undo the last change
- Ctrl-r - Redo the last change
- Ctrl-g - Show the current line and column
Configuration Commands
- :help runtimepath - Review your config
- :h rtp - Review your config
- gx - Open links
Where Does Neovim Look For Config Files?
$HOME/.config/nvim/init.lua
What Language Is Used To Write Config Files?
It uses the Lua programming language, which provides better performance and more modern features than VimScript.
How Do I Review My Config?
:help runtimepath or :h rtp
How Do I Add A Custom Config?
Update the init.lua
file with the following:
require('my_config')
How Do I Add A Plugin?
Download the plugin and place it in the ~/.config/nvim
directory.
Update the init.lua
file with the following:
require('markdown-preview')
How Do I Open Links?
Select the link and press:
gx
Learn Neovim - Beyond the Basics
- Books
- Practical Vim - A comprehensive guide to Vim/Neovim mastery
References
- The Lua programming language - Official Lua documentation and resources