Installing vim-ruby on Ubuntu 7.10

January 7th, 2008  | Tags:

A good tool to programming in Ruby is the native VIM from Linux. However the default version does not have the vim-ruby plugin.

In this topic, I am going to show how to install vim-ruby on Ubuntu 7.10 and use this tool. Fortunately this is a simple process.

If you do not have acknowledge about vim, try to type “vimtutor” on shell and a good tutorial about it will appear.

Installing vim-ruby plugin

Let’s create the vim-ruby from shell.

sudo apt-get install vim-ruby

Creating the .vimrc file

You must create a file called “.vimrc” inside your home directory (in my case, in /home/jair).

This file should contains the following content:

try
  source $REAL_HOME/.vimrc
catch /E484/
endtry
syntax on

set nocompatible    " We're running Vim, not Vi!
filetype on         " Enable filetype detection
filetype indent on  " Enable filetype-specific indenting
filetype plugin on  " Enable filetype-specific plugins
set backspace=2     " allow backspacing over everything in insert mode
set history=1000    " keep 1000 lines of command line history
set incsearch       " do incremental searching
set ic              " ignore case in search patterns
set showcmd         " display incomplete commands
set nosol           " cursos is kept in the same column (if possible)
set sw=4            " identation now takes just 4 spaces at a time

set ruler           " show the cursor position all the time
set hlsearch        " highlight searches
set nobackup        " do not keep a backup file
set ignorecase      " ignore case when searching
set title           " show title in console title bar
set ttyfast         " smoother changes
set tabstop=4
set shiftwidth=4    " numbers of spaces to (auto)indent
set scrolloff=3     " keep 3 lines when scrolling
set expandtab       " tabs are converted to spaces, use only when required
set sm              " show matching braces, somewhat annoying...
set smartcase        " Do case insensitive matching
" set number        " show line numbers
" set noignorecase  " don't ignore case
" set nowrap        " don't wrap lines
" set ls=2          " allways show status line
" set laststatus=2  " always display the status line
" set cindent       " cindent

let loaded_vimspell = 1

autocmd FileType text setlocal textwidth=78
autocmd Filetype ruby source ~/.vim/ruby-macros.vim

Installing the vim-ruby gem

Let’s install the vim-ruby gem. Put the following commands on the shell:

gem install vim-ruby --remote --include-dependencies

vim-ruby-install.rb

Downloading the ruby-macros.

Download the ruby-macros.vim from this site.

Copy it to ~./vim directory.

Testing the VIM

After the steps above, the vim-ruby is installed and ready for use.

Try to create a simple file called Test.rb. Insert some ruby commands into this file and see the colors, ident and the code completation through Ctrl+X+O.

Looks good, doesn’t it?

Also you can run your code in background simply clicking Shift + K. It is really useful to code.

Remember, this topic talks about Ruby (not Rails). On the future, I am going to write how to configure VIM to work with Rails.

  1. January 8th, 2008 at 15:06
    #1

    Very interesting article, waiting for the Vim and Rails one.

TOP