Change log
  • 2022-01-29: Add deprecation notice
  • 2021-01-17: Install nvim via tar ball instead of appimage
  • 2020-12-01: Add detailed guide on installing Neovim on Linux

TL;DR: My complete nvim configuration is here. Follow the guide in that location on how to use information technology. Nearly of the config below also applies to Windows and Mac. For how to configure Neovim on Windows, you may also be interested in this postal service.

2022-01-29: Note that this mail is written more than three years agone. Some of the plugins mentioned hither may not be maintained or may not be the best fit for Neovim, or even not need anymore, e.yard., highlighted yank is builtin in Neovim since May 2022. I accept shared some of the plugin changes in this post.

Vim is a popular code editor on Unix/Linux systems, and information technology is oft compared with Emacs, another great code editor amid programmers. The debate well-nigh which one is the best editor never cease. Vim is powerful, but it has its own shortcomings equally an erstwhile editor1. Over the years, Vim'south code base has grown increasing larger, which makes information technology difficult for maintenance and for adding new features quickly. It has only one core developer, Bram Moolenaar. Although Vim has a lot of contributors, almost all patches are merged by Bramtwo. To overcome the shortcomings of Vim, preserve its advantages (i.e., compatible with Vim) and make the development of Vim faster, the Neovim project is created.

In this post, I will requite a detailed guide on how to install Neovim and configure information technology equally an IDE-similar environs for Python evolution (in the rest of this post, I will use Neovim and Nvim interchangeably).

Install Nvim

Neovim has pre-built binary parcel for Linux, you can download information technology from the Neovim GitHub release page:

            mkdir -p              $HOME/tools/              &&              cd              $Habitation/tools/ wget https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz tar zxvf nvim-linux64.tar.gz                      

The executable file is located in $HOME/tools/nvim-linux/bin/nvim.

Now, nosotros need to add the bin directory to the system PATH. Open .bash_profile and add the post-obit line:

                          export              PATH              =              $Dwelling/tools/nvim-linux64/bin:$PATH                      

Relieve the file and source information technology to make the change have effect.

At present, Neovim has been installed on your organisation successfully. You can open neovim on last with nvim command.

Nvim configuration file

Neovim use a different configuration file from Vim. You need to create a file named init.vim nether the directory $HOME/.config/nvim (if this directory does not exist, just create one)iii. All configurations can be put into this file.

About of the configuration options for Neovim are the same with Vim. You can copy your vim configurations if you have used Vim earlier.

Install and use a plugin director

1 of main reasons for the powerfulness of Vim comes from the various plugins written for it. With these plugins, you can achieve all sorts of crazy things which are hard to achieve with plain Vim. If yous have installed a lot of plugins manually, you will find it difficult to manage them. Like Vim, Neovim does not accept a built-in plugin manager. We need to install one ourselves.

There are two plugin managers in wide utilise amid Nvim users. One is dein and the other is vim-plug. Vim-plug has a larger user base and seems more popular. Finally, I decided to give vim-plug a attempt.

Install vim-plug

  1. Install vim-plug itself:
            gyre -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs              \                                          https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim                      

After installing vim-plug, you may need to restart Nvim.

  1. Edit init.vim and add the configuration for vim-plug. I bear witness an example configuration below (modified from the vim-plug GitHub folio):
                          call              plug#begin              (              '~/.local/share/nvim/plugged'              )                                                                                    Plug              'davidhalter/jedi-vim'                                                                                    call              plug#end              ()                                                  

Note that all the plugin installation command must exist put inside the ii call control above. I volition not repeat that later on.

How to use vim-plug

You tin can execute post-obit command in Nvim command mode:

  • Install plugins::PlugInstall
  • Update plugins::PlugUpdate
  • Remove plugins::PlugClean (First, comment the plugin install command in init.vim. Open Nvim and employ :PlugClean to uninstall plugins)
  • Check the plugin status::PlugStatus
  • Upgrade vim-plug itself::PlugUpgrade

Disable a plugin only temporarily

If you want to disable certain plugin for a while but do not want to delete it, you tin can try two methods:

  1. Annotate out the plugin and reopen Nvim.

  2. According to discussions hither, to disable plugin foo/bar, y'all can use the post-obit settings:

                          Plug              'foo/bar'              ,              {              'on': [] }                                    

Plugin install and settings

Automobile-completion plugin deoplete

deoplete is an machine-completion plugin designed for Neovim:

Deoplete is the abbreviation of "dark powered neo-completion". It provides an extensible and asynchronous completion framework for neovim/Vim8.

Strictly speaking, it is an auto-completion engine. In gild to enable auto-completion for a certain programming language, you need to install the corresponding source.

Deoplete is piece of cake to install. Utilize the following settings inside the vim-plug calls:

                          Plug              'Shougo/deoplete.nvim'              ,              {              'exercise':              ':UpdateRemotePlugins'              }                                    

The minimum setting for deoplete is equally follows:

                          let              g:deoplete#enable_at_startup              =              1                                                  

For more options and their meanings, check :h deoplete-options inside Nvim.

Install plugin deoplete-jedi

As I have said, deoplete supports auto-completion for diverse languages via different sources. In club to do auto-completion for Python, we demand to install deoplete-jedi. In the following, I list the steps to install deoplete-jedi.

Step 1: Install dependency packages

First we need to install pynvim,

Nosotros besides demand to install jedi. If you happen to employ the latest version of Anaconda, jedi is already installed. Otherwise, y'all tin install jedi via pip:

Step 2: Install and set deoplete-jedi

First, we need to install deoplete-jedi using vim-plug:

            Plug 'zchee/deoplete-jedi'                      

After that, if cypher wrong happens, you can utilize auto-completion now! Open a Python source file with Nvim and commencement editing, y'all will see the motorcar-completion pop-upward menu like what is shown in the post-obit prototype:

How to use deoplete

  1. How to navigate between the items in the auto-completion list?

According to discussions hither, you tin navigate through the auto-completion list with <Ctrl-N> and <Ctrl-P>.

  1. How to automatically shut the method preview window?

When we navigate through the machine-completion listing, a minor window will appear on top of current window and gives hints about the parameters of current selected method. Only this window will not disappear afterward motorcar-completion is done. Co-ordinate to discussions hither, we tin use the following setting to close the preview window automatically:

                          autocmd              InsertLeave              ,              CompleteDone              *              if              pumvisible              ()              ==              0              |              pclose              |              endif                                                  
  1. How can I open the preview window below the current window?

By default, preview windows will open up on top of current window. You can change this behaviour by adding set up splitbelow in the configuration file. For more info, come across here.

  1. How tin I navigate through the motorcar-completion list with Tab?

Add the post-obit setting in the Nvim configuration file:

            inoremap <expr><tab> pumvisible() ? "\<c-n>" : "\<tab>"                      

Status bar plugin: vim-airline

The default condition bar of Nvim is elementary and tin not provide much useful information like Sublime Text or other modern code editors. Yet, the status bar tin can be customized to achieve wonderful effects. An excellent plugin is chosen vim-airline, which can attain the same functionalities as Sublime Text status bar. It is easy to install:

            Plug 'vim-airline/vim-airline'                      

Use :PlugInstall to install this plugin and restart Nvim. You should be able to run into the new condition bar with more information displayed.

Switch vim-airlinetheme

Vim-airline provides a lot of themes for you to customize your condition bar. Check here to encounter what unlike theme looks similar. Vim-airline has put the various themes in another plugin called vim-airlinetheme. To change the theme, we demand to install this plugin:

                          Plug              'vim-airline/vim-airline-themes'                                                  

And so, in the Nvim configuration file, add the post-obit settings:

                          let              one thousand:airline_theme              =              '<theme>'              " <theme> is a valid theme name                                                  

Automatic quote and bracket completion

When input quote and bracket, nosotros oftentimes wish to input them as pairs. Nvim does non back up this feature. Motorcar-pairs can achieve this and much more than. Just install it:

            Plug 'jiangmiao/auto-pairs'                      

How to use

Let'due south have manipulating double quotes as an example. In insert model, press ", it will automatically become two double quotes. At the aforementioned time, the cursor is placed between the two double quotes, waiting for input. When you finish inputing text between the quotes, you may desire to place the cursor subsequently the right quote and go along inserting text. Here comes the magic part: simply printing " one more time, and the cursor volition be placed correct backside the right quote.

Different programming languages have different specifications for annotate. It would be great to alter the comment style for the current file based on its file type. nerdcommenter is ane such plugin. Install it with vim-plug:

                          Plug              'scrooloose/nerdcommenter'                                                  

To comment out a single line, employ <leader>cc (leader is a prefix key in Nvim, the default leader key is backslash \); to uncomment a line, use <leader>cu. To comment or uncomment several lines, add together a repeating number to corresponding command, but like what yous do in apparently Vim. For more usages, check nerdcommenter'due south documentation.

code auto-format plugin

Neoformat can be used to format your source code. Install it with vim-plug:

For Python code, you need to install a Python code formatter to work together with neoformat. We volition choose yapf. First, we install this formatter with pip:

Then, yous tin format Python code with yapf formatter using neoformat.

How to format code?

In control mode, input Neoformat, neoformat volition auto-format your source code.

If neoformat tin can not find your file type or you lot haven't installed any formatter. Y'all can add the following command to your Nvim configuration to permit neoformat do some basic format for the file:

                          " Enable alignment                                                        permit              g:neoformat_basic_format_align              =              1                                                                                    " Enable tab to space conversion                                                        let              g:neoformat_basic_format_retab              =              1                                                                                    " Enable trimmming of trailing whitespace                                                        let              g:neoformat_basic_format_trim              =              1                                                  

At that place is another format plugin vim-autoformat which you can try.

Code jump (go-to) plugin

We often need to leap to the definition of form and method to check their implementation details. We can apply jedi-vim to accomplish this. Actually, jedi-vim tin can too do code auto-completion. Since we have installed deoplete and deoplete-jedi, we can disable code completion and only utilize the code jumpt office of jedi-vim. Install jedi-vim with vim-plug:

            Plug 'davidhalter/jedi-vim'                      

Utilize the following simple configuration:

                          " disable autocompletion, considering we use deoplete for completion                                                        let              g:jedi#completions_enabled              =              0                                                                                    " open up the get-to role in carve up, not another buffer                                                        let              g:jedi#use_splits_not_buffers              =              "right"                                                  

How to apply jedi-vim

Motility the cursor to the class or method you want to cheque, and then printing the various supported shortcut provided past jedi-vim:

  • <leader>d: get to definition
  • Thou: cheque documentation of class or method
  • <leader>north: show the usage of a proper noun in electric current file
  • <leader>r: rename a proper name

File managing and exploration plugin

Those who have been working with GUI lawmaking editors are familiar with the sidebar on the left side of the code editor, which provides an overview of files and folders in current project. How practice nosotros achieve like functions in Nvim? You tin apply nerdtree. First, install information technology using vim-plug:

                          Plug              'scrooloose/nerdtree'                                                  

How to apply nerdtree?

  1. How to open file navigation window?

In control mode, input :NERDTree to open the directory your current file resides.

  1. How practise I open up a file in the file explorer?

Place the cursor in the file you want to open and printing o to open up this file in the correct window.

  1. How do I switch between file window and nerdtree file navigation window?

This is the same as how you switch windows in Vim. Printing ctrl and printing w two times quickly to switch window. You lot can also press <Ctrl-westward> and so printing L.

  1. How practise I exit or close file explorer window?

Printing q while your cursor is this window? Or apply NERDTreeClose control in command mode.

For more customization, refer to this post.

Code checker plugin

Neomake is a tool for code syntax check and build automation for Nvim. Install it with vim-plug:

Neomake's syntax cheque for diverse languages relies on diverse linters. Later on installation, you need to install linters according to your programming languages. The linter for different languages are listed here.

For Python, we can use pylint as linter. Install pylint with pip or conda:

            conda install pylint # pip install pylint                      

After installing pylint, we need to set it in init.vim as the Python lawmaking checker:

            permit g:neomake_python_enabled_makers = ['pylint']                      

Lawmaking checking

In command mode, use Neomake control to get-go syntax check. We tin can also enable automatic code check. Just add together the following setting in Nvim configuration file:

            call neomake#configure#automake('nrwi', 500)                      

Pylint checks extensively on your lawmaking, which makes information technology a bit wearisome. Another code linter y'all can try is flake8, which is faster.

Multiple cursor editing plugin

If you accept used Sublime Text earlier, you must exist impressed by Sublime Text'due south ability to edit multiple position in the code simultaneously. This function is keen when you desire to refactor your lawmaking. You lot can achieve similar office with the help of vim-multiple-cursors. Install information technology with:

                          Plug              'terryma/vim-multiple-cursors'                                                  

How to utilise

In normal mode, move the cursor to a variable you desire to rename, printing <Ctrl-Northward> and this variable will be highlighted. Keep press <Ctrl-Due north>, the next occurrence of this variable will be highlighted. If you want to skip a certain occurrence (for instance, a string may contain a sub-cord which is the aforementioned as the variable), simply press <Ctrl-X> after this position has been highlighted. Continue selecting the occurrence of this variable until all its occurrence has been selected.

Now, printing c (in Nvim, c means to change ) and enter insert mode. Input a new name and salvage.

Simply, I should say that this plugin is not perfect. When y'all accept a lot of occurrences of the variable in the file, the refactor of variable proper noun is dull.

There are some discussions about Neovim's native support for multiple cursors. But it seems that this office is nonetheless non finished as of today. You tin find relevant discussions in the following links:

  • https://github.com/neovim/neovim/bug/3845
  • https://github.com/neovim/neovim/issues/211
  • https://github.com/neovim/neovim/issues/7257
  • https://github.com/onivim/oni/issues/184

Highlight your yank area

In Nvim, if you yank (i.e., copy) a cake of text, you practise non get a visual hint about exactly what you accept copied. Unless you are very familiar with Nvim, yous may have copied less or more than what y'all want to copy, which is annoying. With the help of vim-highlightedyank, you tin now highlight the text region which yous have yanked. Handy little feature, isn't it?

You tin can install it with vim-plug:

                          Plug              'machakann/vim-highlightedyank'                                                  

Nearly of the time, you lot practice not need any further settings subsequently installing this plugin. Only, for some colorschemes, you volition non exist able to run across the highlight colors. To fix this result, add the post-obit setting to Nvim configuration:

                          hi              HighlightedyankRegion              cterm              =              reverse              gui              =              contrary                                                  

If you feel that the highlight elapsing fourth dimension is besides short, you can increase the highlight duration (measured in ms):

                          " set up highlight duration time to 1000 ms, i.east., 1 second                                                        let              g:highlightedyank_highlight_duration              =              g                                                  

Lawmaking folding plugin

For big code base of operations, it is helpful to fold some part to get a ameliorate idea of the structure of the code. SimplyFold is prissy plugin for code folding. Install information technology with vim-plug:

                          Plug              'tmhedberg/SimpylFold'                                                  

You practise not need further settings. It works out of the box.

simple usage

There are some shortcuts to dispense code folding:

  • zo: Open fold in current cursor position
  • zO: Open fold and sub-fold in current cursor position recursively
  • zc: Close the fold in current cursor position
  • zC: Close the fold and sub-fold in current cursor position recursively

Theme install and configuration

Before we begin

Neovim has several built-in colorschemes or themes. You may not like them and want meliorate themes. It is easy to install a theme. But information technology is lilliputian tricky to brand the theme display correctly every bit what the theme homepage shows. A lot of themes will non brandish well if you use an SSH client which has poor back up for true colors. For Windows system, after trying several SSH clients, I find that ZOC works all-time. For Mac, you tin utilise the open source tool iTerm2. To find more SSH clients which support truthful colors, visit this page.

Install themes

Gruvbox is a popular Vim colorscheme. Install it with vim-plug:

Then use :PlugInstall to install it simply like you install other plugins.

In Nvim configuration file, activate this theme with the following setting:

Information technology has 2 modes, i.e., dark and light, which can be switched using the following settings:

                          set              background              =              dark              " use night style                                                        " fix groundwork=calorie-free " uncomment to use low-cal mode                                                  

Restart Nvim and you will activate the new theme. Information technology looks like the following on my Mac:

Other themes

At that place are other themes you may desire to try:

  • one dark
  • monokai
  • jellybeans
  • NeoSolarized

How practice I modify the font?

Unlike Sublime Text, you can not prepare which font to use in Nvim's configuration. Instead, Nvim will use the font you choose for your terminal emulator. So you lot need to gear up your favorite font in the terminal. Some good programming fonts are:

  • Hack
  • FiraCode
  • Source Lawmaking Pro

Cheque nerd fonts for more programming fonts.

How to notice more than interesting plugins?

In that location is a website chosen vimawesome, which collects information about various Vim plugins. Yous tin observe helpful plugins on this website.

Since almost Vim plugins are published on GitHub, you can as well search with vim and other keywords on GitHub to notice relevant plugins. For example, search vim colorschem or vim theme to find themes designed for Vim.

Builtin concluding

Neovim has back up for terminal emulator so that you can directly run a shell inside Neovim. It is handy for temporary shell operations.

To open the terminal, use :terminal or :vnew term://fustigate or new term://bash. Later entering the last, y'all are in normal mode. Press i to start typing terminal control.

To get out insert way in last emulator, press <Ctrl+\><Ctrl+N>.

To exit terminal emulator and close the window, use get out.

The deviation between Nvim and Vim

Back up for bracketed paste way

Neovim has support for bracketed paste mode. The paste option in Vim is obsolete. Use :h paste and you will the following documentation:

This option is obsolete; bracketed-paste-mode is built-in.

Neovim is all nocompatible

In Nvim normal style, use :h comatible, and y'all will come across that:

Nvim is always "nocompatible"

For more differences between Nvim and Vim, see here.

Trouble shooting

In this part, I introduce some issues found when using Nvim and how to fix these event.

Nvim colorscheme does not look correct inside Tmux

If your final supports truthful colour, first install the latest version of tmux4, add the following config to ~/.tmux.conf (extracted from here)

            prepare -one thousand default-terminal "screen-256color" prepare -ga terminal-overrides ",xterm-256color*:Tc"                      

Then the color should be fine. Otherwise, in the Nvim config file init.vim, apply the following setting instead:

As well, there are some discussions here.

How exercise I get a log file when starting Neovim

Use nvim -VNUMnvim.log. NUM is used to point verbose level, for instance:

The above command creates a log file nvim.log with verbose level 10.

More than reference here. Run across also nvim --aid.

OK, that is finish of this long post. Y'all tin can notice my complete Nvim configurations here. Happy Viming!


  1. Vim was start released in 1991. Its predecessor is Vi, built-in in 1978. ↩︎

  2. Developers would send a patch to Bram. Bram will review information technology so merge information technology on GitHub if he thinks the patch is ok. ↩︎

  3. For Windows, the config directory is dissimilar. Open neovim and run command :repeat stdpath('config') to find the verbal directory. ↩︎

  4. Check hither on how to build the latest version of tmux from source. ↩︎