installing vim-ruby

Nikolai Weibull mailing-lists.vim-ruby-development at rawuncut.elitemail.org
Wed Oct 12 04:42:31 EDT 2005


Mark Volkmann wrote:

> Here's what I did to install vim-ruby.
> 
> gem install vim-ruby
> ruby vim-ruby-install.rb (from my RUBY_HOME/bin directory)
> 
> I don't get errors from either of these.

Hooray.

> I have the following in my .vimrc file (_vimrc under Windows).
> 
>       set nocompatible      " We're running Vim, not Vi!

'compatible' is unset by default if you run vim or gvim (i.e., when
sourcing .vimrc or .gvimrc - or _vimrc, :h 'compatible' for more
information).  

>       syntax on             " Enable syntax highlighting
>       filetype on           " Enable filetype detection
>       filetype indent on    " Enable filetype-specific indenting
>       filetype plugin on    " Enable filetype-specific plugins

The last three can be written as

filetype plugin indent on

> When I start a new vim session and edit a .rb file, it doesn't appear
> to have vim-ruby features enabled. For example, when I enter "if name
> == "John" and press shift-Enter, it moves to the next line and indents
> two spaces, but it does not add "end" to the subsequent line.

How is that an example of what vim-ruby should do?  The Shift-Enter
auto-completion code isn’t in vim-ruby.  That’s something Pit Captain
has added to the rubygarden wiki so that you can added to your own
~/.vim/(after/)?ftplugin/ruby.vim if you want to.

Here’s an even sweeter binding that I use in my
~/.vim/after/ftplugin/ruby.vim:

inoremap <buffer> <CR> <C-O>:call <SID>CompleteStatement()<CR><CR>

function! s:CompleteStatement()
  " TODO: we can check contents of ". register to make sure that they were
  " inserted while typing here...
  if getline('.') =~ '^\s*\%(begin\|case\|class\|def\|for\|if\|module\|unless\|until\|while\)\>\|do\%(\s*|[^|]*|\s*\)\=$'
    let n = indent('.')
    let ind = ''
    let i = 0
    while i < n
      let ind .= ' '
      let i += 1
    endwhile
    call append(line('.'), ind . 'end')
  endif
endfunction

> Am I missing a step to get vim-ruby installed correctly?

No, but you can’t expect it to do stuff not advertised,
        nikolai

-- 
Nikolai Weibull: now available free of charge at http://bitwi.se/!
Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}


More information about the vim-ruby-devel mailing list