1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

Version Control and a Solid Editor

By

3 of 4

Vim (or Another Editor)
Version Control and a Solid Editor

Vim may not be your chosen editor, it does have a learning curve and some people just want to jump right in. Other choices include gedit, emacs or the ever popular Sublime Text.

Most distros come with some kind of basic editor, such as nano and gedit. While they can be used to code Ruby (gedit in particular, as it's extensible and pretty capable), my editor of choice is Vim with the NerdTree script. We'll be installing Vim, pathogen (which makes installing vim scripts easier), NERDTree and set up syntax highlighting and auto indentation with two spaces. So we start off with a simple apt-get.


$ sudo apt-get install vim vim-gtk

Create a few vim directories and install pathogen.


$ mkdir -p ~/.vim/autoload ~/.vim/bundle
$ curl -Sso ~/.vim/autoload/pathogen.vim \
    https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
$ echo 'execute pathogen#infect()'  >> ~/.vimrc

You need to set up a few things in your vimrc file. You can either copy /usr/share/vim/vimrc to ~/.vimrc as a starting point, or copy and paste my vimrc from below. Pay special attention to the pathogen infect line, you need that in order for pathogen to work.


set nocompatible

set shiftwidth=2
set tabstop=2
set softtabstop=2
set expandtab
set noswapfile

if has("gui_running")
  colorscheme desert
  set guioptions=-m
  set guifont=Monospace\ 9
  set columns=150
  set lines=50
endif

execute pathogen#infect()

And now install NERDTree.


$ cd ~/.vim/bundle
$ git clone https://github.com/scrooloose/nerdtree.git
See More About
  1. About.com
  2. Technology
  3. Ruby
  4. Tutorials
  5. Ruby on Windows the Easy Way
  6. Installing Git and Vim

©2014 About.com. All rights reserved.