Vim as an IDE

I use vim daily, and am the kind of Linux person to snicker at those using nano, pico and all the lesser editors of the world. But recently a project I was working on became a bit more complex both in size and structure that I needed vim to have a bit more umpf than just the normal powers it was providing. So I started to do some research and discuss with other developers around the world to find the best solution to me. Mainly because I haven’t jumped on the whole IDE/Eclipse movement and don’t want to lose vim as a tool.

Fortunately, it appears I am not the only person who needs/wants these functionalities in an editor and was able to find the perfect solution for me and hopefully you. Vim as an IDE gives me the flexibility of vim and the powers of auto completion and syntax highlighting without the overhead of a JVM and clunky GUI. Lets get started.

I run on a Fedora workstation so for any other distro or Windows/Mac see:
https://github.com/Valloric/YouCompleteMe#installation

Short Demo

Here you will see a quick example of me changing a few variables and the autocompletion functionality YouCompleteMe provides.

If you haven’t already, install vim with some prerequisites

sudo dnf install vim automake gcc gcc-c++ kernel-devel cmake python-devel git

Depending on your os you may need to use another package manager (apt, yum, brew, etc)

Download and Configure Vundle

Vundle is a vim plugin management system that will help you install all the things nice and easily.

cd ~
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

Add the following to the top of your .vimrc

set nocompatible
filetype off
 
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
 
Plugin 'VundleVim/Vundle.vim'
Plugin 'Valloric/YouCompleteMe'
 
call vundle#end()
filetype plugin indent on

This is needed to complete the install Vundle as well as YouCompleteMe.

Install Vundle and YCM

Now we will actually install Vundle and YouCompleteMe, YouCompleteMe is a library to add auto completion functionality to vim.

vim +PluginInstall +qall

Compile C++ Libraries for Fast Auto Completion

cd ~
mkdir ycm_build
cd ycm_build
cmake -G "Unix Makefiles" . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
cmake --build . --target ycm_support_libs --config Release

Now, when you open up a any development project in vim you will get the following features.

Quick Feature Summary

General (All Languages)

  • Super-fast identifier completer including tags files and syntax elements

  • Intelligent suggestion ranking and filtering

  • File and path suggestions

  • Suggestions from Vim’s OmniFunc

  • UltiSnips snippet suggestions

C-family languages (C, C++, Objective C, Objective C++)

  • Semantic auto-completion

  • Real-time diagnostic display

  • Go to include/declaration/definition (GoTo, etc.)

  • Semantic type information for identifiers (GetType)

  • Automatically fix certain errors (FixIt)

  • View documentation comments for identifiers (GetDoc)

C#

  • Semantic auto-completion

  • Real-time diagnostic display

  • Go to declaration/definition (GoTo, etc.)

  • Semantic type information for identifiers (GetType)

  • Automatically fix certain errors (FixIt)

  • Management of OmniSharp server instance

  • View documentation comments for identifiers (GetDoc)

Python 2

  • Intelligent auto-completion

  • Go to declaration/definition (GoTo, etc.)

  • View documentation comments for identifiers (GetDoc)

Go

  • Semantic auto-completion

  • Management of gocode server instance

Typescript

  • Semantic auto-completion

  • Go to definition (GoToDefinition)

  • Semantic type information for identifiers (GetType)

  • View documentation comments for identifiers (GetDoc)

Javascript

  • Intelligent auto-completion

  • Go to definition, find references (GoToDefinition, GoToReferences)

  • Type information for identifiers (GetType)

  • View documentation comments for identifiers (GetDoc)

  • Management of Tern server instance

Rust

  • Semantic auto-completion

  • Go to definition (GoTo, GoToDefinition, and GoToDeclaration are identical)

  • Management of racer server instance

Write a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.