If you’ve ever used Linux, you might have heard of Vim.
Don’t run away just yet.
Yes, Vim is not exactly the easiest text editor in the world, but it is one of the most powerful available. Vim isn’t...
If you’ve ever used Linux, you might have heard of Vim.
Don’t run away just yet.
Yes, Vim is not exactly the easiest text editor in the world, but it is one of the most powerful available. Vim isn’t just a text editor; it’s a highly configurable and powerful text editor that’s popular among programmers because it’s a very efficient tool for coding in the command line.
Vim allows users to issue complex commands via keyboard shortcuts, so your fingers never have to leave the keys. Vim can also be extended with plugins to add IDE functionality.
But what is Neovim?
Neovim is an extensible fork of Vim that is designed to simplify managing the app, improve usability, offer better plugin support and include built-in Language Server Protocol (LSP) and support for modern GUIs and UIs. Neovim maintains core compatibility with Vim, but offers a much more streamlined experience.
If the idea of developing from a terminal app and the command line sounds up your alley, Neovim might be the right tool for you.
Neovim includes features like:
Better default settings than Vim.
A sleek API for plugins.
Focus on out-of-the-box usability.
A powerful Lua API and the ability to break configurations into modules to make complex setups more manageable.
Handles tasks like linting, syntax checking and file indexing.
A built-in, fully scriptable terminal emulator.
Supports most existing Vim plugins.
Let’s get Neovim installed and configured.
Installing Neovim
Neovim can be installed on Linux, macOS (using brew) and Windows. Here’s how it’s done:
Note: To use the plug-in system, you have to install the nightly version (more on that in a bit).
Configuring Neovim
Once you have Neovim installed, you can certainly use it as is. Of course, given how flexible and extensible the tool is, you’ll want to create your own config file.
To create a config file, you must first create the necessary directory. I’m going to demonstrate this on Linux. If you’re using either macOS or Windows, you’ll need to alter the location of the config file accordingly.
Create the new directory with:
Create the config file with:
In that file, you’re going to add all your configuration options. A sample config might look like this:
You can find a complete listing of options in the Neovim documentation.
Once you’ve created your config file, save it with Ctrl+X.
Plugins
Neovim can use vim-plug as a plug-in manager. The only problem is that a lot of plugins won’t function properly unless you’re using the nightly build, which can be found here.
To install the nightly version on Ubuntu, follow these steps:
With that taken care of, install vim-plug, which is done with the command:
Now that those steps are taken care of, let’s use a little cheat to make things easier. There’s a script called Kickstarter that makes it really easy to set up Neovim. To use Kickstarter, you’ll want to move the init.vim file out of your nvim directory and then issue the following command:
After that, start Neovim to load Kickstarter. The command to run the app is:
Once it loads, you’ll find yourself in the Neovim window, where you can begin using the editor.
To load a plugin, you use the :packadd command like this:
After that, you then invoke the plugin like this:
The DiffTool plugin compares two directories or files side by side, and supports directory diffing, rename detection and highlights changes.
Use the Built-in Tutorial
At this point, I would highly recommend using the interactive tutorial, which will greatly help with your introduction to Neovim. To start the tutorial, exit out of Neovim with the following command:
Back at your terminal window, issue the command:
This interactive tutorial will really help you understand how to get up to speed with Neovim, and given how much there is to learn, this should be an absolute must for anyone just getting started.
Seriously, the tutorial is a must.
Neovim is a very powerful text editor that, with some upfront configurations, could replace your current editor for programming and much more. Yes, it has a step learning curve, but the built-in tutorial will go a long way to helping you out.
The post Is Neovim Your Next Favorite Development Tool? appeared first on The New Stack.