
Introduction to Neovim
What is Neovim?
Neovim is a terminal-based text editor that has been around for several years. It is a fork of the famous vim, but with superpowers that let you use it in a much broader and more comfortable way.
Neovim is characterized by its versatility and extensibility, giving users an incredible range of configuration options despite being a fully text-based editor. However, Neovim has a steep learning curve since it’s a terminal editor — using the mouse for navigation is ruled out. But this doesn’t have to be a limitation; Neovim has a vast number of shortcuts that make the experience truly enjoyable.
Why Neovim and not Vim?
Although Neovim started as a fork of Vim, its goal was always to improve extensibility and code maintainability. Key advantages include:
- Native LSP: Built-in support for the Language Server Protocol, giving you autocompletion and IDE-level code navigation.
- Lua as a first-class citizen: Forget complex Vimscript. Lua is a lightweight, powerful, and easy-to-learn scripting language.
- Asynchrony: Heavy tasks don’t block your user interface.
How do I install Neovim?
Depending on your operating system, you’ll find several ways to install Neovim. Below are the recommended methods for each platform:
macOS
On macOS, the recommended option as of this post’s publication date is to install Neovim via Homebrew:
brew install neovim
Linux
On Linux, the installation method is similar to macOS:
sudo apt-get install neovim
Windows
On Windows, Neovim is only supported on Windows 8 and later, and you need a package manager. This example uses Winget:
winget install Neovim.Neovim
After running the appropriate command for your OS, you should have the
nvim command available in your terminal. This command is the entry point
to start using this incredible tool.
By the time you read this post, these installation methods may have changed. If so, check the official Neovim documentation for the most up-to-date information.
How do I start using Neovim?
As mentioned earlier, Neovim is a terminal editor — you edit files directly from the terminal. Open your preferred terminal and navigate to the folder containing the files you want to edit.
Assuming the file you want to edit is called my-file.txt inside a folder
called my-folder in your Documents directory:
nvim ~/Documents/my-folder/my-file.txt
Now for the biggest myth of vi/vim/nvim: how do you exit?
First, make sure you’re in normal mode by pressing Esc. Then use one of these methods:
-
: to enter command mode, then type q (quit) and press Enter. If there are unsaved changes you want to keep, type wq (write and quit) instead.
-
ZZ: a shortcut to save and exit immediately. If there are unsaved changes, it won’t let you exit. Save first by pressing : then w + Enter, then try ZZ again.