Monday, February 6, 2012

Vim as a Universal IDE {Part 2 (Ruby/Rails )}

when a Newbie starts coding with ruby , it seems hard to switch between files
and running scripts .It seem a lot of time consuming with coding
ruby . Many people ask on irc and groups daily which is best IDE for Ruby.Or
some those used Textmate,Eclispe ,etc.. are also facing time consumption
while write some code! SO ! SO! SO! Now Solution is VIM!

I already Explained basic Installation and working on vim in my previous post
those who are new to vim can visit Part 1 for basic editing and installation
,configuration of vim for better use

I explain here some useful plug-in and working,configuration of those .This
post help ! you to shape code perfect with vim and ruby.
Comments Welcome !!

1) For Enhanced Syntax Highlighting & Navigation(rails.vim)
 automatically detects buffers ,it effect only rails script not ruby scripts
.Easy navigation and interface to script ,integration with other plugins.such
NERDtree.vim with :Rtree

install details
extract the zip to ~/.vim

Download page is here http://www.vim.org/scripts/script.php?script_id=1567

2)Organization of project like (IDE/Buffer)
this help you launch a .*.jpg files in a viewer. I have also set
up viewers for PDF (acroread) and HTML files (mozilla) for my own use.

install details
untar the file in ~/.vim
for untar use this command :- tar -xzvf filename
download page link is here  http://www.vim.org/scripts/script.php?script_id=69

3)Ruby filetype and indentation
:-

a)for Ruby indentation :download indentation script and extract(gunzip
filename) gzip  in ~/.vim/indent
download link is here  http://www.vim.org/scripts/script.php?script_id=2742
along with this you need install a plugin Indentanything

install details for that is here    
cd ~/.vim
tar zxvf IndentAnything.tar.gz
download page link is here http://www.vim.org/scripts/script.php?script_id=1839

b)matchit.zip
: extended % matching for HTML, LaTeX, and many other
languages The matchit.vim script allows you to configure % to match more    than just single characters.  You can match words and even regular expressions.
Also, matching treats strings and comments (as recognized by the
syntax highlighting mechanism) intelligently.
The default ftplugins include settings for several languages:
Ada, ASP with VBS, Csh, DTD, Essbase, Fortran, HTML, JSP
(same as HTML), LaTeX, Lua, Pascal, SGML, Shell, Tcsh, Vim, XML.
(I no longer keep track, so there may be others.)

install details
extract zip in ~/.vim

download page link is here http://www.vim.org/scripts/script.php?script_id=39
your .vimrc config must have below one
filetype plugin on

c)ruby-matchit:- Map '%' to jump from one keyword to its corresponding
'end' in Ruby files. Inspired by 'matchit.vim' that comes with Vim

install details

Put the file in ~/.vim/ftplugin/ruby/ directory
download page http://www.vim.org/scripts/script.php?script_id=290


4)Database excess ( dbext.vim) : Provides database access to many dbms such as: Mysql, PostgreSQL, Ingres, Oracle, Oracle Rdb (VMS), Sybase Adaptive Server Anywhere, Sybase Adaptive Server Enterprise,iMicrosoft SQL Server, DB2, Interbase and SQLite and ODBC are supported. 
 install deatils
 extract zip in ~/.vim
 download page is here http://www.vim.org/scripts/script.php?script_id=356



 5) Haml and Sass syntax, indenting, and ftplugin :-

 Runtime files for Haml and Sass.
 install details
 Extract in ~/.vim or ~\vimfiles.
 download page is here http://www.vim.org/scripts/script.php?script_id=1433




6) Ruby-test
:- Rubytest.vim will help you to run ruby test (including        vanillatest, rspec, shoulda etc.) in vim.

Installation
Unzip downloaded file and copy rubytest.vim to your ~/.vim/plugin directory.
download page for the this http://www.vim.org/scripts/script.php?script_id=2612

Your .vimrc config you need to do is below
let g:rubytest_cmd_test = "ruby %p"
let g:rubytest_cmd_testcase = "ruby %p -n '/%c/'"
let g:rubytest_cmd_spec = "spec -f specdoc %p"
let g:rubytest_cmd_example = "spec -f specdoc %p -e '%c'"            
let g:rubytest_cmd_feature = "cucumber %p"
let g:rubytest_cmd_story = "cucumber %p -n '%c'"

Default keybind to change

map <Leader>\ <Plug>RubyTestRun " change from <Leader>t to <Leader>\
map <Leader>] <Plug>RubyFileRun " change from <Leader>T to <Leader>]
map <Leader>/ <Plug>RubyTestRunLast " change from <Leader>l to <Leader>/
     


7) cucumber runtime :- description
This provides syntax highlighting, indenting, and a filetype plugin for
Cucumber, the acceptance testing framework

install details
Extract in ~/.vim

download page   http://www.vim.org/scripts/script.php?script_id=2973


8) Endwise.vim
: Wisely add :-
  This is a simple plugin that helps to end certain structures automatically.In Ruby, this means adding "end" after "if", "do", "def" and several other
  keywords. In Vim Script, this amounts to appropriately adding "endfunction","endif", etc

  install deatils
  install in ~/.vim/plugin
  download page is here http://www.vim.org/scripts/script.php?script_id=2386



  9) Genutils : General utility functions :-

  This script provides functions that are mostly useful to script developers,but some of the functions can be easily converted to good utilities.
  install details
  extarct in ~/.vim 
  download page http://www.vim.org/scripts/script.php?script_id=197


 now config your .vimrc
command! -nargs=0 -range=% SortByLength <line1>,<line2>call QSort(
        \ 'CmpByLineLengthNname', 1)
command! -nargs=0 -range=% RSortByLength <line1>,<line2>call QSort(
        \ 'CmpByLineLengthNname', -1)
command! -nargs=0 -range=% SortJavaImports <line1>,<line2>callQSort(
        \ 'CmpJavaImports', 1)


u might like the following mappings to adjust spacing:
nnoremap <silent> <C-Space> :call ShiftWordInSpace(1)<CR>
nnoremap <silent> <C-BS> :call ShiftWordInSpace(-1)<CR>
nnoremap <silent> \cw :call CenterWordInSpace()<CR>
nnoremap <silent> \va :call
AlignWordWithWordInPreviousLine()<CR>

The :find command is very useful to search for a file in path, but it
doesn't support file completion. Add the following command in your vimrc
to add this functionality
nd! -nargs=1 -bang -complete=customlist,genutils#UserFileComplete2
            \ FindInPath :find<bang> <args>

If you are running commands that generate multiple pages of output, you
might find it useful to redirect the output to a new buffer. Put the
following command in your vimrc:
nd! -nargs=* -complete=command Redir
          \ :new | put! =GetVimCmdOutput('<args>') | setl bufhidden=wipe |
          \ setl nomodified

10) multvals.vim
: Array library that uses patterns as separators An array is
nothing but a string of multiple values separated by a
pattern.  The simplest example being Vim's multi-value variables such as
tags. You can use the MvAddElement() function to create an array.
However, there is nothing special about this function, you can as well
make up the string by simply concatenating elements with the chosen
pattern as a separator.

install in ~/.vim/plugin
download page is here http://www.vim.org/scripts/script.php?script_id=171

Some other plugin such as Nerd tree or git integration ,supertab ,code navigation are  used in previous post for python. Also textmate like completion and indentation also discuss in previous part .


Note:- Stay Tuned more parts of this Post coming soon for Ruby,C++,C,Closure,Prolog ,Haskell,Java,PHP,Perl,Shell, JavaScript ,HTML,CSS Coming soon (within few Days) .
Update of this post will done soon for Usage of plugin and more config Details .Also preparing image graphics for all post soon update all with how use effectively all these  plug-ins.


                                                                     THANKS FOR VISITING


LHS AS A SOURCE OF INFORMATION – AND A SOURCE OF INSPIRATION – I HOPE YOU’LL CHOOSE TO ACT RIGHT NOW.ENJOY KEEP LEARNING.

   

2 comments: