Skip to content

Migrate from ViM to neovim

Migrate from ViM to neovim published on

Links used:

Main Steps

To use your existing .vimrc you can do this:

cat << EOF > ~/.config/nvim/init.vim
set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath
source ~/.vimrc
EOF

But if you want different init.vim than .vimrc (probably a good idea in the start phase) copy your stuff to:

cp -r ~/.vim/bundle ~/.config/nvim/bundle/
cp ~/.vimrc ~/.config/nvim/init.vim

You then could add a file ~/.config/nvim/ginit.vim for nvim-qt the Gvim equivalent of nvim. The normal distinction with has(gui_running) does not work properly. We can add all GUI Neovim specific stuff there, for my side it is something like:

colorscheme peachpuff
"map ctrl-tab to switch splits in terminal mode
nmap <silent> <C-Tab> :wincmd w<CR>

"open full screen
call rpcnotify(0, 'Gui', 'WindowMaximized', 1)

" Set Gui Font (`set guifont=` does not work in nvim-qt)
if has('nvim')
    GuiFont FreeMono:10
else

But later stuff in my .vimrc, like opening NERDTree, did not work in ginit.vim. For that I have extended my diff in init.vim:

if (has('gui_running') || get(g:, 'GuiLoaded', 1))

There is further a bug in nvim-qt in the newer package than the one from bionic, to open an additional empty buffer, see " https://github.com/equalsraf/neovim-qt/issues/423

This can be fixed with three lines at the end of init.vim:

if @% == ""
  bd
endif

Now you can use it with your ViM configuration. There is one difference, my beloved command gvim -d does not work directly, we have to use nvim-qt -- -d file1 file2. With Termina nvim, everything is ok.

Vundle Troubleshoot

To update Plugins, you probably have to change your Vundle configuration:

set rtp+=~/.config/nvim/bundle/Vundle.vim
call vundle#begin("~/.config/nvim/bundle")

now you can run :PluginInstall and :PluginUpdate

Make Neovim Default

Add alternatives, for gvim somehow already /usr/bin/gvim.nvim-qt exist.

sudo update-alternatives --install $(which vim) vim $(which nvim) 10

and then config your choice:

sudo update-alternatives --config vim
sudo update-alternatives --config gvim

Syntax Highlighting for NGINGX on Vim

Syntax Highlighting for NGINGX on Vim published on No Comments on Syntax Highlighting for NGINGX on Vim

nginx.conf for Vim

https://gist.github.com/2called-chaos/5073996

#!/bin/sh
mkdir -p ~/.vim/syntax/
cd ~/.vim/syntax/
wget http://www.vim.org/scripts/download_script.php?src_id=19394
mv download_script.php\?src_id\=19394 nginx.vim
cat > ~/.vim/filetype.vim << EOF
au BufRead,BufNewFile /etc/nginx/*,/usr/local/nginx/conf/* if &ft == '' | setfiletype nginx | endif
EOF
Categories