Nice, have you got any config snippets you wouldn't mind sharing?
I'll paste in my .vimrc and my .irbrc file (the latter was lovingly
lifted from JEG2)
vimrc
---------------
" An example for a vimrc file.
"
set nobackup
set nocompatible
set backspace=3Dindent,eol,start
set history=3D50=09=09" keep 50 lines of command line history
set ruler=09=09" show the cursor position all the time
set showcmd=09=09" display incomplete commands
set incsearch=09=09" do incremental searching
map Q gq
set autoindent=09=09" always set autoindenting on
set shiftwidth=3D2
set tabstop=3D2
set expandtab
set tw=3D80
set nohlsearch
map <silent> <C-N> :se invhlsearch<CR>
filetype on
filetype indent on
filetype plugin on
syntax on
if !exists( "*EndToken" )
function EndToken()
let current_line =3D getline( '.' )
let braces_at_end =3D '{\s*\(|\(,\|\s\|\w\)*|\s*\)\?$'
if match( current_line, braces_at_end ) >=3D 0
return '}'
else
return 'end'
endif
endfunction
endif
noremap <F5> :set invpaste paste?<Enter>
imap <F5> <C-O><F5>
set pastetoggle=3D<F5>
map <C-R> :!ruby %<CR>
map <C-A> :!rake<CR>
map <C-I> :!ri <cword><CR>
imap <C-L> <ESC>:execute 'normal o' . EndToken()<CR>O
imap <C-B> def test_<C-L><BS><BS><BS><BS><BS><BS>
"{{{ Ruby block delimiter conversion: do end <=3D> { }
"Copyright (c) 2005 Mauricio Fernandez
"Subject to same licensing terms as Ruby.
" requires matchit and friends
" since it uses the % and =3D bindings
function! s:String_Strip(str)
let s =3D substitute(a:str, '\v^\s*', '', '')
return substitute(s, '\v\s*$', '', '')
endfunction
function! s:RubyBlockBraceToDoEnd(lineno)
" { } =3D> do end
let oldz =3D getreg("z")
call setreg("z", "")
execute 'normal ^f{%l"zd$'
let suffix =3D s:String_Strip(getreg("z"))
call setreg("z", oldz)
let orig =3D getline(".")
let repl =3D substitute(orig, '\v\s*\{\s*(\|[^|]*\|)?.*', ' do \1', '')
call setline(".", repl)
let nextline =3D substitute(orig, '\v[^{]*\v\s*\{\s*(\|[^|]*\|)?', '', =
'')
let nextline =3D substitute(nextline, '\}[^}]*$', '', '')
let numlines =3D 0
" uncomment one of the following:
" (1) just insert the body without splitting the lines on ;
"call append(a:lineno, nextline)
"call append(a:lineno+1, 'end' . suffix)
"
" (2) try to split on ; ...
call append(a:lineno, 'end' . suffix)
" this is what we would want to do:
"let nextline =3D substitute(nextline, ';', "\n", 'g')
while stridx(nextline, ";") !=3D -1
=09let eom =3D stridx(nextline, ";")
=09let line =3D s:String_Strip(strpart(nextline, 0, eom))
=09call append(a:lineno + numlines, line)
=09let numlines =3D numlines + 1
=09let nextline =3D strpart(nextline, eom+1, strlen(nextline) - eom - 1)
endwhile
let nextline =3D s:String_Strip(nextline)
if strlen(nextline) > 0
=09call append(a:lineno + numlines, nextline)
=09let numlines =3D numlines + 1
endif
" this is what it all began with...
"execute 'normal :s/\v\s*\{\s*(\|.*\|)?/ do \1\r/
'
"execute 'normal g_cw
end=1B'
execute 'normal V' . (1 + numlines) . 'j=3D'
"echo "{ } =3D> do end"
endfunction
function! s:RubyBlockDoEndToBrace(_firstline, _lastline)
" do end =3D> { }
let linenum =3D a:_firstline + 1
let orig =3D getline(".")
while linenum < a:_lastline - 1
=09let addline =3D getline(linenum)
=09if '\v^\s*$' !~ addline
=09 let addline =3D substitute(addline, '\v^\s*', '', '')
=09 let addline =3D substitute(addline, '\s*$', '; ', '')
=09 let orig =3D orig . addline
=09endif
=09let linenum =3D linenum + 1
endwhile
let l =3D substitute(getline(a:_lastline-1), '\v^\s*', '', '')
let l =3D substitute(l, '\s*$', '', '')
let orig =3D orig . l
let l =3D substitute(getline(a:_lastline), '\v^\s*end(\.|\s|$)@=3D', ' =
}', '')
let l =3D substitute(l, '\s*$', '', '')
let orig =3D orig . l
"echo orig
"input(orig)
let repl =3D substitute(orig, '\v\s*do\s*(\|[^|]*\|)?', '{\1 ', '')
"execute 'normal d' . (a:_lastline - a:_firstline) . 'j'
execute ':' . a:_firstline . ',' . a:_lastline . 'd'
call append(a:_firstline - 1, repl)
execute ':' . a:_firstline
"echo "do end =3D> { }"
endfunction
map <SID>xx <SID>xx
let s:sid =3D maparg("<SID>xx")
unmap <SID>xx
let s:sid =3D substitute(s:sid, 'xx', '', '')
function! <SID>RubyBlockSwitchDelimiters() range
set nofoldenable
if a:firstline =3D=3D a:lastline
=09let braceidx =3D match(getline("."), '{')
=09let doidx =3D match(getline("."), '\<do\>')
=09if braceidx !=3D -1 && (doidx =3D=3D -1 || braceidx < doidx)
=09 call s:RubyBlockBraceToDoEnd(a:firstline)
=09elseif doidx !=3D -1
=09 execute 'normal /\<do\>' . "\n" . 'V%:call ' .
=09=09=09\ s:sid . 'RubyBlockSwitchDelimiters()' . "\n"
=09else
=09 echo "No block found"
=09end
else
=09call s:RubyBlockDoEndToBrace(a:firstline, a:lastline)
endif
"execute 'normal V2k=3D'
"execute 'normal v5j'
endfunction
command! -range B <line1>,<line2>call <SID>RubyBlockSwitchDelimiters()
vmap <Leader>B :call <SID>RubyBlockSwitchDelimiters()<cr>
------
and .irbrc
------
require 'irb/completion'
ARGV.concat [ "--readline" ]
if $0 =3D=3D "irb"
IRB.conf[
ROMPT][:XMP][:RETURN] =3D "\# =3D> %s\n"
IRB.conf[:EVAL_HISTORY] =3D 1000
IRB.conf[:SAVE_HISTORY] =3D 100
HISTFILE =3D "~/.irb.hist"
MAXHISTSIZE =3D 100
begin
if defined? Readline::HISTORY
histfile =3D File::expand_path( HISTFILE )
if File::exists?( histfile )
lines =3D IO::readlines( histfile ).collect {|line| line.ch=
omp}
puts "Read %d saved history commands from %s." %
[ lines.nitems, histfile ] if $DEBUG || $VERBOSE
Readline::HISTORY.push( *lines )
else
puts "History file '%s' was empty or non-existant." %
histfile if $DEBUG || $VERBOSE
end
Kernel::at_exit {
lines =3D Readline::HISTORY.to_a.reverse.uniq.reverse
lines =3D lines[ -MAXHISTSIZE, MAXHISTSIZE ] if
lines.nitems > MAXHISTSIZE
$stderr.puts "Saving %d history lines to %s." %
[ lines.length, histfile ] if $VERBOSE || $DEBUG
File:
pen( histfile,
File::WRONLY|File::CREAT|File::TRUNC ) {|ofh|
lines.each {|line| ofh.puts line }
}
}
end
end
def ri(*names)
system(%{ri #{names.map {|name| name.to_s}.join(" ")}})
end
end