Enabling Ruby syntax highlighting and autocomplete using MacVim

mvim snapshot

Steps:

  1. Download and use MacVim using Homebrew:
    1. brew install macvim
  2. (If above doesn’t work to highlight .rb files automatically or if you prefer using vim instead of macvim)
    1. Download vim-ruby zip from: https://github.com/vim-ruby/vim-ruby
    2. Follow manual “Manually” instructions to install from a script file: https://github.com/vim-ruby/vim-ruby/wiki/VimRubySupport
    3. Enable extensions within your ~/.vimrc
      1. set nocompatible " We're running Vim, not Vi!
        syntax on " Enable syntax highlighting
        filetype on " Enable filetype detection
        filetype indent on " Enable filetype-specific indenting
        filetype plugin on " Enable filetype-specific plugins
  3. (Optional: enable better tabbing)
    1. Edit your ~/.vimrc with the following contents
      1. set smartindent
        set tabstop=2
        set shiftwidth=2
        set expandtab

Usage:

  • Open a file in the terminal using: mvim -v <FILE_NAME>
  • Initiate auto-complete prompt by hitting CTRL-X CTRL-O
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s