In this post, I will write about how to install and configure Neovim on Windows 101.

Before we begin

The builtin CMD on Windows is awful. It is strongly recommended to use a better terminal emulator, for example, Cmder, which installs git for Windows and other utilies.

Install

You can download the latest compiled release file from Neovim GitHub repo. Then extract the package and add the extracted folder to your PATH so that you can invoke nvim on your command line.

Configuration

Where to put the configuration file

According to Neovim official documentation, you should put neovim config file init.vim under directory ~/AppData/Local/nvim.

Install plugin-manager vim-plug

To install vim-plug on Windows, open a PowerShell terminal (not Windows CMD), and execute the following command:

md ~\AppData\Local\nvim\autoload
$uri = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
(New-Object Net.WebClient).DownloadFile(
  $uri,
  $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(
    "~\AppData\Local\nvim\autoload\plug.vim"
  )
)

In Neovim config file, use the following settings for vim-plug:

call plug#begin('~/AppData/Local/nvim/plugged')
" below are some vim plugin for demonstration purpose
Plug 'joshdick/onedark.vim'
Plug 'iCyMind/NeoSolarized'

Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
call plug#end()

When you use :PlugInstall, all the plugins will be installed under ~/AppData/Local/nvim/plugged. You can change this directory to what you want.

Issues

The Neovim window content is not cleared when I exit

When I exit Neovim, the window content in Neovim is still shown in the command line, wasting a lot of space. How to clear the Neovim window content after quit?

After some research, I have finally found a solution which works for Cmder. Open Cmder settings and go to Startup -> Environment, add the following settings:

set TERM=xterm-256color

Restart Cmder and the issue should disappear. More discussions here.

Can not enter Neovim if there are errors in config file

If there are errors in your Neovim config file, during start up, Neovim will prompt you:

Press ENTER or type command to continue

However, pressing Enter key has no effect. Neovim will stuck here unless you press Ctrl-C to terminate this process.

To circumvent this issue, according to here, try to open Neovim with the following option:

nvim --cmd silent!

Some shortcuts does not work

For Cmder, Ctrl-W is used to close a console. Unfortunately, this shortcut is also used by Neovim as Windows switching prefix. There are maybe some other conflicting shortcuts, for example, Ctrl-V does work like Linux.

To disable the conflicting shortcuts in Cmder, go to Keys & Macro part to change or disable a shortcut.

<Ctrl-6> does not work?

On Linux, we can use Ctrl-^(actually Ctrl-6) to switch buffers. But on Windows, I find that using <Ctrl-6> for buffer switching does not work. I try to map Ctrl-6 to Ctrl-^:

nnoremap <C-6> <C-^>

It doesn’t work either. Until I find the solution , I use Ctrl+shift+6 to switch buffers.

References


  1. It should work for Windows 7 as well.