Autocompletion really makes everything much easier in life, especially when it comes to programming. One of the most famous Autocompletion plugin for VIM is called YouCompleteMe, and unlike most of the plugins for VIM, it’s actually a bit more of a pain in the ass to install.
For this tutorial, we’ll be using Pathogen (you can click here for the author’s git), which is a very simple VIM plugin/bundle manager. In case you don’t have it installed, don’t worry because it’s very easy to install. We will also be needing those programs/applications installed:
sudo apt-get install build-essential
)sudo apt-get install cmake
)sudo apt-get install python-dev python2.7-dev python3-dev
)sudo apt-get install git
)First up, open up your Terminal and clone the git of the project:
mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
Finally, you need to add this at the top of your vimrc:
execute pathogen#infect()
And that’s really all there is to it for pathogen. Now moving on to the next one: YouCompleteMe. This one is far more tricky to install and I personally ran into a lot of problems while installing it for the first time. First, we need to clone the git and update its submodules:
cd ~/.vim/bundle
git clone https://github.com/Valloric/YouCompleteMe.git
cd YouCompleteMe
git submodule update --init --recursive
If you want to have all C families included in the plugin:
./install.sh --clang-completer
If you don’t want to have all C families included in the plugin:
./install.sh
Make sure you have at least 1GB RAM to install YouCompleteMe or it will crash in the middle of installing. This happened to me on my VPS, and the only way I found to fix this is to set up a swap of 1GB on top of the existing 512MB I already had installed.
SuperTab is a much easier to install compared to YouCompleteMe, mainly because it uses VIM’s completion. Furthermore, since it’s much more lightweight, you don’t need to have at least 1GB of RAM, 512MB worked just fine for me. The major difference between YouCompleteMe and SuperTab is that SuperTab requires you to press on TAB to trigger the autocompletion function, but it’s extremely easy to get used to.