UPDATE (2025): I wanted to give a quick update on this since I’ve moved on from using vim, and now exclusively use Neovim, along with LazyVim, which is a Neovim setup powered by lazy.vim to make it easy to customize and extend your config - but the big win out of the box is a sane set of defaults so you can get to work, and revist the wonderful world of Neovim later when you want to add/edit the current settings. It’s a much better base than what I used to try to do with old vim, and I’ve started writing an Ansible playbook to handle this for me, regardless of Linux distro, if I’m on a desktop, server or whatever.
Steps to setup Neovim
- Install Neovim with your package manager, for example for my use cases:
Alpine Linux
apk add neovimArch Linux
pacman -S neovimDebian GNU/Linux
apt install neovimFedora
yum install neovim- Configure LazyVim, they have a really simple walkthrough on their installation page, basically there are 4 steps:
- backup current neovim (aka nvim) settings if you already have them:
mv ~/.config/nvim{,.bak}mv ~/.local/share/nvim{,.bak}mv ~/.local/state/nvim{,.bak}mv ~/.cache/nvim{,.bak}Note: if you’ve just installed neovim, or don’t have these directories already it might complain, but ignore that, you don’t need to backup those directories since you weren’t using them prior.
- Clone the starter code from LazyVim, this will drop their configuration into your config directory so you don’t have to do anything else:
git clone https://github.com/LazyVim/starter ~/.config/nvim- Remove the .git folder from the LazyVim checkout, this way you can edit it, and later add it to your own repo if you want to save your changes.
rm -rf ~/.config/nvim/.git- Start Neovim, which will find the new config and it will handle the installation of all the required plugins and modules, so give it about a minute and watch the progress.
nvim-
Done. Now edit any file in Neovim and you’ll be amazed at how fully it’s configured, without having to really do anything. Things with vim, different ways to install plugins, inconsistancies, etc used to really drive me nuts, and was the inital reason for this post! Now things are much better.
-
Bonus! Since I only want to use Neovim, and not vim, going forward, I configure some settings in my user’s
${HOME}/.profileso that typingvi,vimwill give me a session in Neovim (nvim) automatically. I also set variables forEDITORandVISUALfor programs that will look for those variables. So edit the file (nvim ~/.profile), and add the following aliases and add the 2 variables:
## aliasesalias vim="nvim"alias vi="nvim"export EDITOR="nvim"export VISUAL="nvim"-
Done, for real this time. For a most historical view continue reading to see how I used to ((try) to bring some sanity to my vi/vim setups in the past!
-
TODO: setup an Ansible playbook to handle the install and setup of Neovim and LazyVim, then also include installation options for FreeBSD and OpenBSD, and have Ansible cover those too.
Original post from 2018:
I’m on new servers pretty often, and usually their vim configuration is quite lacking, I mean, come on /etc/skel can only get you so far these days.. While I have my .vimrc out there, copying it down fails because I don’t have the right version of vim installed, plus I’m missing plugins and other goofy stuff I call out that should be in my $HOME/.vim directory. So, here’s a start to get me rolling on a new server with a decent, basic vimrc setup so I can get to work. I’ll update this as I go, and once I have it ready I’ll redo my deploy scripts to run Ansible to properly “get the game started” (Slackware reference for my old timers out there!). Until then, this will do:
#!/bin/sh
# in Debian based GNU/Linux distros (Debian, Ubuntu, Kali...)# TODO make a conditional to cover other distrossudo apt install vim
git clone --depth=1 https://github.com/amix/vimrc.git ~/.vim_runtime
sh ~/.vim_runtime/install_basic_vimrc.sh
exit 0