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

TL;DR: My complete nvim configuration is hither. Follow the guide there on how to utilize it. Most of the config below likewise applies to Windows and Mac. For how to configure Neovim on Windows, yous may likewise be interested in this postal service.

2022-01-29: Notation that this post is written more than than iii years ago. Some of the plugins mentioned here may not be maintained or may not be the best fit for Neovim, or even non need anymore, e.g., highlighted yank is builtin in Neovim since May 2022. I have shared some of the plugin changes in this mail.

Vim is a pop lawmaking editor on Unix/Linux systems, and information technology is often compared with Emacs, another slap-up code editor among programmers. The fence about which ane is the best editor never terminate. Vim is powerful, but information technology has its ain shortcomings equally an sometime editor1. Over the years, Vim'south code base of operations has grown increasing larger, which makes information technology hard for maintenance and for calculation new features quickly. It has only one core developer, Bram Moolenaar. Although Vim has a lot of contributors, nearly all patches are merged past Bram2. 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 mail, I will give a detailed guide on how to install Neovim and configure it as an IDE-similar environs for Python development (in the rest of this postal service, I volition use Neovim and Nvim interchangeably).

Install Nvim

Neovim has pre-built binary package for Linux, yous can download it from the Neovim GitHub release page:

            mkdir -p              $HOME/tools/              &&              cd              $Home/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, we demand to add the bin directory to the arrangement PATH. Open up .bash_profile and add the following line:

                          consign              PATH              =              $Habitation/tools/nvim-linux64/bin:$PATH                      

Save the file and source it to brand the change take upshot.

Now, Neovim has been installed on your organization successfully. You can open neovim on terminal with nvim command.

Nvim configuration file

Neovim utilize a unlike 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, merely create one)3. All configurations tin can exist put into this file.

Most of the configuration options for Neovim are the aforementioned with Vim. You can copy your vim configurations if you accept used Vim before.

Install and utilize a plugin manager

One of main reasons for the powerfulness of Vim comes from the various plugins written for it. With these plugins, you tin accomplish all sorts of crazy things which are difficult to accomplish with obviously Vim. If yous have installed a lot of plugins manually, yous will observe information technology hard to manage them. Like Vim, Neovim does not have a built-in plugin director. Nosotros demand to install ane ourselves.

There are two plugin managers in broad use among Nvim users. 1 is dein and the other is vim-plug. Vim-plug has a larger user base and seems more popular. Finally, I decided to requite vim-plug a try.

Install vim-plug

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

Later installing vim-plug, yous may need to restart Nvim.

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

Note that all the plugin installation control must be put inside the two call command to a higher place. I volition not echo that afterwards.

How to use vim-plug

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

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

Disable a plugin only temporarily

If you desire to disable certain plugin for a while simply practice not want to delete information technology, y'all tin endeavour two methods:

  1. Comment out the plugin and reopen Nvim.

  2. According to discussions here, to disable plugin foo/bar, you can utilise the post-obit settings:

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

Plugin install and settings

Auto-completion plugin deoplete

deoplete is an auto-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 lodge to enable motorcar-completion for a sure programming linguistic communication, you need to install the respective source.

Deoplete is easy to install. Utilise the post-obit settings within the vim-plug calls:

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

The minimum setting for deoplete is as follows:

                          let              chiliad:deoplete#enable_at_startup              =              1                                                  

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

Install plugin deoplete-jedi

Equally I have said, deoplete supports automobile-completion for various languages via different sources. In society to do auto-completion for Python, we need to install deoplete-jedi. In the post-obit, I list the steps to install deoplete-jedi.

Stride 1: Install dependency packages

First we need to install pynvim,

We also need to install jedi. If y'all happen to apply the latest version of Anaconda, jedi is already installed. Otherwise, you can install jedi via pip:

Step ii: Install and prepare up deoplete-jedi

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

            Plug 'zchee/deoplete-jedi'                      

After that, if nothing wrong happens, you tin can use car-completion now! Open a Python source file with Nvim and start editing, y'all will run into the auto-completion pop-upward menu similar what is shown in the following image:

How to utilize deoplete

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

According to discussions here, you can navigate through the auto-completion listing with <Ctrl-N> and <Ctrl-P>.

  1. How to automatically close the method preview window?

When nosotros navigate through the motorcar-completion listing, a modest window will appear on top of current window and gives hints almost the parameters of current selected method. Simply this window volition not disappear afterward car-completion is washed. According to discussions here, we can utilise the following setting to close the preview window automatically:

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

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

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

Add the following 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 unproblematic and can not provide much useful information like Sublime Text or other mod code editors. Yet, the status bar can exist customized to achieve wonderful effects. An excellent plugin is called vim-airline, which can reach 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 see the new status bar with more information displayed.

Switch vim-airlinetheme

Vim-airline provides a lot of themes for you lot to customize your status bar. Check hither to see what dissimilar theme looks similar. Vim-airline has put the various themes in another plugin called vim-airlinetheme. To modify the theme, we demand to install this plugin:

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

Then, in the Nvim configuration file, add the following settings:

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

Automatic quote and bracket completion

When input quote and bracket, we oft wish to input them equally pairs. Nvim does not support this feature. Auto-pairs tin can achieve this and much more. Simply install it:

            Plug 'jiangmiao/auto-pairs'                      

How to utilize

Let's take manipulating double quotes every bit an instance. In insert model, press ", it will automatically become two double quotes. At the same fourth dimension, the cursor is placed betwixt the two double quotes, waiting for input. When you finish inputing text betwixt the quotes, you may want to place the cursor after the right quote and go on inserting text. Here comes the magic part: just press " 1 more than time, and the cursor will be placed correct behind the correct quote.

Unlike programming languages have different specifications for comment. Information technology would be swell to alter the annotate fashion for the current file based on its file type. nerdcommenter is one such plugin. Install information technology with vim-plug:

                          Plug              'scrooloose/nerdcommenter'                                                  

To comment out a single line, employ <leader>cc (leader is a prefix cardinal 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, just like what yous practice in plain Vim. For more usages, check nerdcommenter's documentation.

code auto-format plugin

Neoformat tin 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 will choose yapf. First, nosotros install this formatter with pip:

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

How to format code?

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

If neoformat can not discover your file type or you lot haven't installed whatsoever formatter. Yous tin can add the following command to your Nvim configuration to let neoformat do some basic format for the file:

                          " Enable alignment                                                        let              thou:neoformat_basic_format_align              =              1                                                                                    " Enable tab to space conversion                                                        let              g:neoformat_basic_format_retab              =              ane                                                                                    " 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.

Lawmaking jump (become-to) plugin

Nosotros ofttimes need to jump to the definition of grade and method to bank check their implementation details. Nosotros can apply jedi-vim to achieve this. Actually, jedi-vim can also do lawmaking motorcar-completion. Since we have installed deoplete and deoplete-jedi, we tin disable code completion and only use the code jumpt function of jedi-vim. Install jedi-vim with vim-plug:

            Plug 'davidhalter/jedi-vim'                      

Use the following simple configuration:

                          " disable autocompletion, because we use deoplete for completion                                                        let              g:jedi#completions_enabled              =              0                                                                                    " open the get-to function in split, not another buffer                                                        let              g:jedi#use_splits_not_buffers              =              "correct"                                                  

How to use jedi-vim

Motion the cursor to the class or method yous desire to check, so printing the diverse supported shortcut provided by jedi-vim:

  • <leader>d: go to definition
  • K: check documentation of class or method
  • <leader>n: bear witness the usage of a name in current file
  • <leader>r: rename a name

File managing and exploration plugin

Those who have been working with GUI code editors are familiar with the sidebar on the left side of the lawmaking editor, which provides an overview of files and folders in electric current project. How do we achieve similar functions in Nvim? You tin use nerdtree. First, install it using vim-plug:

                          Plug              'scrooloose/nerdtree'                                                  

How to utilise nerdtree?

  1. How to open file navigation window?

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

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

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

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

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

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

Press q while your cursor is this window? Or use NERDTreeClose control in command mode.

For more customization, refer to this mail.

Lawmaking checker plugin

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

Neomake's syntax bank check for various languages relies on various linters. After installation, you need to install linters according to your programming languages. The linter for different languages are listed here.

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

            conda install pylint # pip install pylint                      

After installing pylint, we need to fix information technology in init.vim as the Python code checker:

            permit chiliad:neomake_python_enabled_makers = ['pylint']                      

Lawmaking checking

In command mode, utilize Neomake command to starting time syntax check. We can as well enable automatic code cheque. Just add the following setting in Nvim configuration file:

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

Pylint checks extensively on your code, which makes it a flake tedious. Another code linter you can endeavor is flake8, which is faster.

Multiple cursor editing plugin

If you take used Sublime Text earlier, yous must be impressed by Sublime Text's power to edit multiple position in the lawmaking simultaneously. This function is bang-up when you want to refactor your code. Y'all tin achieve similar function with the help of vim-multiple-cursors. Install information technology with:

                          Plug              'terryma/vim-multiple-cursors'                                                  

How to use

In normal fashion, movement the cursor to a variable you want to rename, press <Ctrl-N> and this variable will exist highlighted. Continue press <Ctrl-Due north>, the next occurrence of this variable will be highlighted. If you lot want to skip a sure occurrence (for example, a string may contain a sub-cord which is the aforementioned as the variable), only printing <Ctrl-X> afterward this position has been highlighted. Continue selecting the occurrence of this variable until all its occurrence has been selected.

Now, press c (in Nvim, c means to alter ) and enter insert mode. Input a new name and save.

But, I should say that this plugin is non perfect. When you have a lot of occurrences of the variable in the file, the refactor of variable name is tedious.

In that location are some discussions about Neovim's native support for multiple cursors. Just it seems that this function is nevertheless not finished as of today. You lot can find relevant discussions in the post-obit links:

  • https://github.com/neovim/neovim/problems/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 expanse

In Nvim, if you yank (i.east., copy) a block of text, you do not get a visual hint nigh exactly what you have copied. Unless you lot are very familiar with Nvim, you may take copied less or more than than what you lot want to copy, which is annoying. With the help of vim-highlightedyank, you lot tin can now highlight the text region which you have yanked. Handy picayune feature, isn't it?

You can install it with vim-plug:

                          Plug              'machakann/vim-highlightedyank'                                                  

Near of the time, you exercise not need whatsoever further settings later installing this plugin. But, for some colorschemes, you will non exist able to see the highlight colors. To fix this issue, add together the following setting to Nvim configuration:

                          hullo              HighlightedyankRegion              cterm              =              reverse              gui              =              reverse                                                  

If you feel that the highlight duration time is likewise short, yous can increase the highlight duration (measured in ms):

                          " fix highlight duration fourth dimension to 1000 ms, i.e., one 2nd                                                        let              yard:highlightedyank_highlight_duration              =              1000                                                  

Code folding plugin

For large code base, it is helpful to fold some part to go a better idea of the structure of the code. SimplyFold is nice plugin for code folding. Install it with vim-plug:

                          Plug              'tmhedberg/SimpylFold'                                                  

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

elementary usage

There are some shortcuts to dispense code folding:

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

Theme install and configuration

Earlier we begin

Neovim has several built-in colorschemes or themes. Yous may not like them and want better themes. It is easy to install a theme. But it is fiddling tricky to make the theme display correctly as what the theme homepage shows. A lot of themes volition not display well if you lot utilize an SSH client which has poor back up for truthful colors. For Windows system, afterward trying several SSH clients, I notice that ZOC works best. For Mac, you can use the open source tool iTerm2. To discover more SSH clients which back up true colors, visit this folio.

Install themes

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

So use :PlugInstall to install it just similar you lot install other plugins.

In Nvim configuration file, activate this theme with the post-obit setting:

It has two modes, i.due east., dark and lite, which tin can be switched using the following settings:

                          set              background              =              dark              " use dark fashion                                                        " set background=light " uncomment to utilize light mode                                                  

Restart Nvim and you lot will actuate the new theme. It looks like the following on my Mac:

Other themes

There are other themes y'all may want to endeavour:

  • one dark
  • monokai
  • jellybeans
  • NeoSolarized

How practice I change the font?

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

  • Hack
  • FiraCode
  • Source Lawmaking Pro

Cheque nerd fonts for more than programming fonts.

How to find more interesting plugins?

At that place is a website called vimawesome, which collects information nigh diverse Vim plugins. You can find helpful plugins on this website.

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

Builtin last

Neovim has support for last emulator so that y'all can directly run a shell inside Neovim. It is handy for temporary beat out operations.

To open up the final, use :last or :vnew term://bash or new term://bash. Afterwards entering the terminal, yous are in normal fashion. Press i to kickoff typing terminal control.

To get out insert mode in concluding emulator, press <Ctrl+\><Ctrl+Due north>.

To exit last emulator and shut the window, use exit.

The divergence between Nvim and Vim

Support for bracketed paste mode

Neovim has back up for bracketed paste mode. The paste option in Vim is obsolete. Utilize :h paste and you volition the post-obit documentation:

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

Neovim is all nocompatible

In Nvim normal mode, use :h comatible, and you will see that:

Nvim is ever "nocompatible"

For more than differences between Nvim and Vim, run into hither.

Trouble shooting

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

Nvim colorscheme does non look right inside Tmux

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

            set -g default-terminal "screen-256color" set -ga last-overrides ",xterm-256color*:Tc"                      

And so the color should be fine. Otherwise, in the Nvim config file init.vim, utilise the following setting instead:

Likewise, there are some discussions hither.

How do I get a log file when starting Neovim

Use nvim -VNUMnvim.log. NUM is used to indicate verbose level, for example:

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

More reference here. See also nvim --assist.

OK, that is stop of this long post. You can find my consummate Nvim configurations here. Happy Viming!


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

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

  3. For Windows, the config directory is different. Open neovim and run command :echo stdpath('config') to find the exact directory. ↩︎

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