Setup Vim as an IDE

Simple steps to setup your Vim as an IDE for python, scala and so on.
If you are not fimiliar with Vim, you can read this blog first: Getting Started with Vim by Vimtutor.

Install spf13-vim

spf13-vim is a distribution of vim plugins and resources for Vim, GVim and MacVim. We firstly install it as the basic IDE and then do some customizations:

1
2
3
4
$ sudo yum update
$ sudo yum install git
$ vim --version # checkout >=7.4
$ curl http://j.mp/spf13-vim3 -L -o - | sh

Useful shortcuts:

  • ctrl + e: open/close NERDTree left tool
  • ctrl + p: search and open files
  • m (inside NERDTree): Open NERDTree Menu
    • a: add file or folder

Customization

For customization, we can create three files:

1
2
3
~/.vimrc.local
~/.vimrc.before.local
~/.vimrc.bundles.local

Make tab equal to 2 spaces:

1
2
$ vim .vimrc.local
autocmd FileType * setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2

Select the language you want to support, it will install related plugins:

1
2
3
4
$ vim .vimrc.before.local
let g:spf13_bundle_groups=['general', 'writing', 'youcompleteme', 'programming', 'scala', 'php', 'ruby', 'python', 'javascript', 'html', 'misc']
let g:spf13_no_autochdir = 1
let g:ycm_path_to_python_interpreter = '/usr/bin/python'

After configration, we need to run the following command inside vim:

1
2
$ vim
:BundleInstall

It will give WARN from youcompleteme plugin, you need to compile it by yourself in next step.

Compile youcompleteme

YouCompleteMe is a powerful code-completion engine for Vim:

1
2
3
4
5
6
$ sudo yum install automake gcc gcc-c++ kernel-devel cmake
$ sudo yum install python-devel python3-devel
# Compiling YCM with semantic support for C-family languages
$ cd ~/.vim/bundle/YouCompleteMe
$ ./install.py --clang-completer

After it completes, do BundleInstall again:

1
2
3
$ Vim
:BundleInstall

ScreenShot

For Scala
Scala

For Python
Python

Contents
  1. 1. Install spf13-vim
  2. 2. Customization
  3. 3. Compile youcompleteme
  4. 4. ScreenShot
|