paint-brush
Changing to Neovimby@claudio.santos.ribeiro
14,126 reads
14,126 reads

Changing to Neovim

by Cláudio RibeiroSeptember 13th, 2018
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Over the past few years, Vim has changed. It has grown and morphed into a more modern piece of software. Something that’s responsive and features rich.

Company Mentioned

Mention Thumbnail
featured image - Changing to Neovim
Cláudio Ribeiro HackerNoon profile picture

Over the past few years, Vim has changed. It has grown and morphed into a more modern piece of software. Something that’s responsive and features rich.

If you’re like me and been using Vim 7.4 for years and years, it came with great surprise that newer and better versions came to be.


Modern Day Vim_When talking about Vim, most people see it as this old, obsolete piece of software from the last century._hackernoon.com

In this piece let’s talk about how we can migrate from Vim 7.4 to a modern version of Vim (Vim 8, Neovim).

Let’s focus on switching to Neovim, because switching to Vim 8 should be almost effortless. The configuration files will be on the same place and once installed it should be working with all your previous configs out of the box.

There are two ways (using Linux) to install Vim 8:

  1. Using the unofficial PPA:
  • sudo apt-add-repository ppa:jonathonf/vim
  • sudo apt update
  • sudo apt install vim

2. Download the latest version from the official website and build it on your own.

For Mac Os users, brew upgrade vim should be enough.

Even though Neovim is a fork of Vim, it’s not exactly the same thing. We could argue it is a totally different piece of software, but that would be somewhat radical. But because it’s different, it has a different way of installing.

Once again, we can either use the PPA:

  • sudo apt-add-repository ppa:neovim-ppa/stable
  • sudo apt update
  • sudo apt install neovim

Or use the package manager: sudo apt install neovim.

For Mac OS user, of course: brew install neovim

Neovim is not Vim, and because of that, using $vim to launch it will not work. The better you’ll get with that command is an outdated version of Vim or Vim 8 if you happen to have it installed. The correct command to launch Neovim is $nvim.

There are ways to make the $vim command behave like $nvim. It involves turning it into an alias for $nvim. There are loads of resources for doing that all over the internet, but making the change in your head shouldn’t be complicated.

One thing that will definitely make our life harder is the fact that all Vim configuration resides on ~/.vimrc. But Neovim uses

~/.config/nvim/init.vim

by default. Because we’re all lazy and don’t want to have configuration files duplicated all over our file system, there’s the option to create a ~/.config/nvim/init.vim with the following content:

set runtimepath^=/.vim runtimepath+=~/.vim/after

let &packpath = &runtimepath

source ~/.vimrc

What this code does is everytime you launch nvim it searches for your .vimrc file and sources it. This way all your already existing configurations will be still running on Neovim.

And by the way,

Congratulations, you just switched to Neovim!

Having trouble with Vim? Don’t know what to put into your .vimrc file? Want to use it for programming? Check out my new book “An IDE Called Vim”. It goes through all the basics of Vim, from installing to using it as an IDE.