Changing to Neovim

Written by claudio.santos.ribeiro | Published 2018/09/13
Tech Story Tags: vim | neovim | changing-to-neovim | software-development | vim-has-changed

TLDRvia the TL;DR App

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.


Published by HackerNoon on 2018/09/13