eigenclass logo
MAIN  Index  Search  Changes  PageRank  Login

Usable Ruby folding for Vim, second update

Jeff Rose suggested a new feature for my Ruby folding voodoo for Vim: comments above a method/class definition should be included in the fold, while keeping the foldtext (so you still see def mymethod(*a) when the fold is closed). It seems I'm developing some tolerance against Vimscript and this was not too hard to implement.

So here's what folds (still) look like


The new behavior is illustrated by the following animation (which also shows the basic usage of my xmp Ruby evaluator/annotator):


You can get the code in Usable Ruby folding for Vim. My .vimrc also contains (in a somewhat more condensed form):

au Filetype ruby setlocal ts=8|setlocal sw=2|setlocal softtabstop=2
au Filetype ruby setlocal expandtab
" fold when switching to that buffer
au Filetype ruby call Foldsearch("")
" *this* is what the current version of my foldsearch-based folding code
" introduces
au Filetype ruby let b:foldsearchprefix='\v^\s*(#.*)?$'

Slightly off-topic - Jan Wikholm (2006-07-11 (Tue) 01:20:44)

Which color scheme are you using?

mfp 2006-07-11 (Tue) 04:40:03

$ grep colorsc .vimrc
colorscheme evening

The animations look really bad due to the poor font choice (I use proggyclean now); on top of that, I'd forgotten to XTerm*boldMode: 0...

.vimrc - matt (2006-01-11 (Wed) 02:20:10)

This is cool stuff, thanks. I prefer to put it in ~/.vim/ftplugin/ruby.vim to help keep my .vimrc uncluttered.

public, private and protected - Per Melin (2005-12-30 (Fri) 17:09:04)

I added |^\s*(public|private|protected)$ at the end of line 84 so that the lines with public, private and protected doesn't get folded, as it can be really confusing when that is hidden (and in the method above no less).

Now it looks like this: vim-ruby-fold-access.png

mfp 2006-01-04 (Wed) 07:08:23

Thank you, I'm adding that.

How'd you do that? - <|:{ (2005-12-13 (Tue) 20:25:31)

How did you do that animation?

mfp 2005-12-14 (Wed) 09:10:43

I use a handy Ruby script named x11rec, plus script/replay. So much useful sw. written by the Japanese Rubylords yet to be discovered...

Last modified:2005/12/12 06:31:59
Keyword(s):[blog] [ruby] [vim] [snippet]