vim lets you do folds like
def method
#{{{
42
#}}}
end
this wreaks havoc on rdoc output, especially when one has
class Foo
#{{{
def bar
end
#}}}
end
any ideas for dealing with this?
-a
vim lets you do folds like
def method
#{{{
42
#}}}
end
this wreaks havoc on rdoc output, especially when one has
class Foo
#{{{
def bar
end
#}}}
end
any ideas for dealing with this?
-a
does this work?
class Fo0
#{{{
# Method comment for bar
def bar
end
#}}}
end
If no, I guess I could add code to ignore them--do many folks use this feature of vim?
Cheers
Dave
On Nov 8, 2004, at 16:43, Ara.T.Howard wrote:
this wreaks havoc on rdoc output, especially when one has
class Foo
#{{{
def bar
end
#}}}
end
does this work?
class Fo0
#{{{# Method comment for bar
def bar
end
#}}}
end
for that case yes... but when i have
class
#{{{
FOO = 42
#}}}
end
it's tough because this IS not comment for FOO
not really (yes- i'm getting bizarre output
i THINK this will work
class Fo0
#--{{{
# Method comment for bar
def bar
end
#--}}}
end
vim seems to understand it and so does rdoc - i need to convert a bunch of
files en masse first to check... should only take about three days before i
figure out ruby's command line edit in place switches (joking)
i'll get back to you...
If no, I guess I could add code to ignore them--do many folks use this
feature of vim?
i don't think many use them - but you'll never go back once you've started!
it makes reading 3000 lines of code a breeze. i think a generic 'ignore' this
comment line no matter what might be nicer than a vim specific feature.
infact i was going to filter my sources to remove the fold markers before i
(think) i found a fix... what do you think about have a pattern/token that
means 'this line, comment or source, is simply disgarded'. the default
pattern could be
/^\s*##/ (double comment symobl)
or mabye
/^\s*#_/ ('private' comment)
or something in that akin... whatever it would be should also be configurable
via option or api...
cheers.
-a
EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
When you do something, you should burn yourself completely, like a good
bonfire, leaving no trace of yourself. --Shunryu Suzuki
===============================================================================
Dave Thomas wrote:
this wreaks havoc on rdoc output, especially when one has
class Foo
#{{{
def bar
end
#}}}
enddoes this work?
class Fo0
#{{{# Method comment for bar
def bar
end
#}}}
endIf no, I guess I could add code to ignore them--do many folks use this feature of vim?
Cheers
Dave
I haven't had cause to use markers to do folding in ruby much, but I do use the feature. I can't remember at the moment whether foldmethod=syntax or foldmethod=indent works well for ruby code.
On Nov 8, 2004, at 16:43, Ara.T.Howard wrote:
the
#{{{ -> #--{{{
fix works. this is my conversion command for anyone interested:
ruby -p -i -e '$_.sub!(%r/^\s*#(\{\{\{|\}\}\})\s*$/, "#--\\1\n")' `find . -name '*.rb'`
yikes.
next question:
how do i tell rdoc to 'treat files with NO extension as ruby files'?
i've tried
-E =rb
and
-E ''=rb
but no luck. my programs never have an extension of 'rb'.
cheers.
-a
IMHO - neither. too many folds. i like to fold class bodies, module bodies,
and function bodies - and that's all. either way above does a LOT more.
-a
On Mon, 8 Nov 2004, Hans Fugal wrote:
I haven't had cause to use markers to do folding in ruby much, but I do use
the feature. I can't remember at the moment whether foldmethod=syntax or
foldmethod=indent works well for ruby code.
EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
When you do something, you should burn yourself completely, like a good
bonfire, leaving no trace of yourself. --Shunryu Suzuki
===============================================================================
No way that I know of, but if you have a shebang line, it'll notice that and use Ruby for the files if the shebang contains 'ruby'
Cheers
Dave
On Nov 8, 2004, at 18:33, Ara.T.Howard@noaa.gov wrote:
how do i tell rdoc to 'treat files with NO extension as ruby files'?
Isn't there a way to limit the number of folds created by
fm=indent?
I would like to use Vim's folding, but there doesn't seem to be a way
to have it just Do The Right Thing. I certainly don't want explicit
fold markers in the code.
Cheers,
Gavin
On Tuesday, November 9, 2004, 11:43:33 AM, Ara.T.Howard wrote:
On Mon, 8 Nov 2004, Hans Fugal wrote:
I haven't had cause to use markers to do folding in ruby much, but I do use
the feature. I can't remember at the moment whether foldmethod=syntax or
foldmethod=indent works well for ruby code.
IMHO - neither. too many folds. i like to fold class bodies, module bodies,
and function bodies - and that's all. either way above does a LOT more.
that doesn't seem to happening for my script - it's very strange and i'm at a
loss as to why, but it defintely does not notice the shebang line. here's the
tar ball of all sources i'm doc'ing:
http://www.codeforpeople.com/rq-1.0.0.tgz
and the command i'm using:
rdoc -a -d -F -S -m README -I jpg -N DEPENDS HISTORY README TODO VERSION bin/* lib/rq.rb lib/*/*
the output i'm looking at, for bin/rq, has not recognized 'rq' as a ruby file
even though it starts with
jib:~/eg/ruby/rq/rq-1.0.0 > head -1 bin/rq
#!/dmsp/reference/bin/ruby
so i'm not sure what's going on.
in any case this isn't too important - just thought you might want to check it
out.
cheers.
-a
On Tue, 9 Nov 2004, Dave Thomas wrote:
On Nov 8, 2004, at 18:33, Ara.T.Howard@noaa.gov wrote:
how do i tell rdoc to 'treat files with NO extension as ruby files'?
No way that I know of, but if you have a shebang line, it'll notice
that and use Ruby for the files if the shebang contains 'ruby'
EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
When you do something, you should burn yourself completely, like a good
bonfire, leaving no trace of yourself. --Shunryu Suzuki
===============================================================================
You can limit the fold nesting with 'foldnestmax'
:set foldnestmax=2
will achieve what you've asked for above.
Regards,
Doug
On Tue, Nov 09, 2004 at 09:43:33AM +0900, Ara.T.Howard wrote:
On Mon, 8 Nov 2004, Hans Fugal wrote:
>I haven't had cause to use markers to do folding in ruby much, but I do use
>the feature. I can't remember at the moment whether foldmethod=syntax or
>foldmethod=indent works well for ruby code.IMHO - neither. too many folds. i like to fold class bodies, module
bodies, and function bodies - and that's all. either way above does a
LOT more.
Isn't there a way to limit the number of folds created by
fm=indent?
yes - but you can say do THIS and THAT level. just a depth
I would like to use Vim's folding, but there doesn't seem to be a way to
have it just Do The Right Thing. I certainly don't want explicit fold
markers in the code.
the markers are nice because they remain when you close/reopen the file...
person opinion i guess...
cheers.
-a
EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
When you do something, you should burn yourself completely, like a good
bonfire, leaving no trace of yourself. --Shunryu Suzuki
===============================================================================
set foldlevel (I use foldlevel=2). As for markers, don't use them, use
syntax based folding. I dunno where I found the file (as it was real
difficult to find) but if anyone wants the custom RubyVim files with
support for syntax based folding and matchit support (% for def, end,
etc.) let me know, I can email them to you.
On Tue, 9 Nov 2004 10:14:45 +0900, Gavin Sinclair <gsinclair@soyabean.com.au> wrote:
On Tuesday, November 9, 2004, 11:43:33 AM, Ara.T.Howard wrote:
> On Mon, 8 Nov 2004, Hans Fugal wrote:
>> I haven't had cause to use markers to do folding in ruby much, but I do use
>> the feature. I can't remember at the moment whether foldmethod=syntax or
>> foldmethod=indent works well for ruby code.> IMHO - neither. too many folds. i like to fold class bodies, module bodies,
> and function bodies - and that's all. either way above does a LOT more.Isn't there a way to limit the number of folds created by
fm=indent?I would like to use Vim's folding, but there doesn't seem to be a way
to have it just Do The Right Thing. I certainly don't want explicit
fold markers in the code.Cheers,
Gavin
Unless you have code like this, right?
class X
class Y
class Z
def foo
end
end
end
end
Gavin
On Wednesday, November 10, 2004, 2:14:21 AM, Doug wrote:
On Tue, Nov 09, 2004 at 09:43:33AM +0900, Ara.T.Howard wrote:
On Mon, 8 Nov 2004, Hans Fugal wrote:
>I haven't had cause to use markers to do folding in ruby much, but I do use
>the feature. I can't remember at the moment whether foldmethod=syntax or
>foldmethod=indent works well for ruby code.IMHO - neither. too many folds. i like to fold class bodies, module
bodies, and function bodies - and that's all. either way above does a
LOT more.
You can limit the fold nesting with 'foldnestmax'
:set foldnestmax=2
will achieve what you've asked for above.
Maybe the fm=syntax option, then? I don't know anything about that,
but it sounds promising.
Gavin
On Tuesday, November 9, 2004, 12:43:34 PM, Ara wrote:
On Tue, 9 Nov 2004, Gavin Sinclair wrote:
Isn't there a way to limit the number of folds created by
fm=indent?
yes - but you can say do THIS and THAT level. just a depth
You can use mkview and loadview to restore the folds
On Tue, 9 Nov 2004 10:43:34 +0900, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:
On Tue, 9 Nov 2004, Gavin Sinclair wrote:
> Isn't there a way to limit the number of folds created by
> fm=indent?yes - but you can say do THIS and THAT level. just a depth
> I would like to use Vim's folding, but there doesn't seem to be a way to
> have it just Do The Right Thing. I certainly don't want explicit fold
> markers in the code.the markers are nice because they remain when you close/reopen the file...
person opinion i guess...cheers.
-a
--> EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
> PHONE :: 303.497.6469
> When you do something, you should burn yourself completely, like a good
> bonfire, leaving no trace of yourself. --Shunryu Suzuki
Yes! I really should send email at this time...
Would it be worth making this configurable in syntax file? I expect
Ara's specified usage to be the most common for those not wanting
maximum folding.
<snip>
Regards,
Doug
On Wed, Nov 10, 2004 at 12:17:10AM +0900, Gavin Sinclair wrote:
On Wednesday, November 10, 2004, 2:14:21 AM, Doug wrote:
> On Tue, Nov 09, 2004 at 09:43:33AM +0900, Ara.T.Howard wrote:
>> On Mon, 8 Nov 2004, Hans Fugal wrote:
>>
>> >I haven't had cause to use markers to do folding in ruby much, but I do use
>> >the feature. I can't remember at the moment whether foldmethod=syntax or
>> >foldmethod=indent works well for ruby code.
>>
>> IMHO - neither. too many folds. i like to fold class bodies, module
>> bodies, and function bodies - and that's all. either way above does a
>> LOT more.> You can limit the fold nesting with 'foldnestmax'
> :set foldnestmax=2
> will achieve what you've asked for above.
Unless you have code like this, right?
Follow-up: it's not promising. Vim's current syntax definition for
Ruby (http://vim-ruby.rubyforge.org) does enable syntax-based folding,
but it can't be selective about what it folds (i.e. classes and
methods only, per Ara's request).
The following settings should be OK:
set foldmethod=syntax
set foldnestmax=2 " or 3
If anyone knows enough about Vim to make the folding smarter for Ruby
files, please step forward
Gavin
On Tuesday, November 9, 2004, 12:47:07 PM, Gavin wrote:
On Tuesday, November 9, 2004, 12:43:34 PM, Ara wrote:
On Tue, 9 Nov 2004, Gavin Sinclair wrote:
Isn't there a way to limit the number of folds created by
fm=indent?
yes - but you can say do THIS and THAT level. just a depth
Maybe the fm=syntax option, then? I don't know anything about that,
but it sounds promising.
What does making it configurable mean? People can already set their
own folding rules in $HOME/.vim/ftplugin/ruby.vim. The syntax rules
should merely be correct.
Gavin
On Wednesday, November 10, 2004, 3:08:09 AM, Doug wrote:
On Wed, Nov 10, 2004 at 12:17:10AM +0900, Gavin Sinclair wrote:
On Wednesday, November 10, 2004, 2:14:21 AM, Doug wrote:
> On Tue, Nov 09, 2004 at 09:43:33AM +0900, Ara.T.Howard wrote:
>> On Mon, 8 Nov 2004, Hans Fugal wrote:
>>
>> >I haven't had cause to use markers to do folding in ruby much, but I do use
>> >the feature. I can't remember at the moment whether foldmethod=syntax or
>> >foldmethod=indent works well for ruby code.
>>
>> IMHO - neither. too many folds. i like to fold class bodies, module
>> bodies, and function bodies - and that's all. either way above does a
>> LOT more.> You can limit the fold nesting with 'foldnestmax'
> :set foldnestmax=2
> will achieve what you've asked for above.
Unless you have code like this, right?
Yes! I really should send email at this time...
Would it be worth making this configurable in syntax file? I expect
Ara's specified usage to be the most common for those not wanting
maximum folding.
If you want to not fold on a particular syntax construct, you need only remove the 'fold' from the end of the 'syn region'.
:help syn-region should help you out.
On Nov 8, 2004, at 5:58 PM, Gavin Sinclair wrote:
On Tuesday, November 9, 2004, 12:47:07 PM, Gavin wrote:
On Tuesday, November 9, 2004, 12:43:34 PM, Ara wrote:
On Tue, 9 Nov 2004, Gavin Sinclair wrote:
Isn't there a way to limit the number of folds created by
fm=indent?yes - but you can say do THIS and THAT level. just a depth
Maybe the fm=syntax option, then? I don't know anything about that,
but it sounds promising.Follow-up: it's not promising. Vim's current syntax definition for
Ruby (http://vim-ruby.rubyforge.org) does enable syntax-based folding,
but it can't be selective about what it folds (i.e. classes and
methods only, per Ara's request).The following settings should be OK:
set foldmethod=syntax
set foldnestmax=2 " or 3If anyone knows enough about Vim to make the folding smarter for Ruby
files, please step forward
I don't know about making folds smarter than you already have.
This is the folding I use with ruby and like, for what that is worth,
as someone who would not like to be without vim folding. I use the
attached folding setup and open ruby (and other files) in folded mode -
it is a bit like having a table of contents. It is made up from things
extracted from vim tips a couple of years back, modified as required
over time.
Lets see what does it include:
<leader>ff folds file
fs after a search, shows only search results all else folded
(no idea whether this feature has become part of mainstream vim)
to open a file in fold mode (i.e. with the fold instructions installed):
gvim -c :R
In additon to folding on def, class, and module (also public protected
private) it folds on #{{ (until the next fold), i use comment markers
and {{ to place folds in all files in which i want fold headings ...
vim setup files included.
There is no recursive (levels of) folding here.
Vim is so flexible how you choose to work with these things is a
matter of taste.
I don't have the time to clean it up, or to extract things (just) ruby
right now but share as is, unedited, (and including some non-ruby folding,
and probably some other superflous bits, actually i did start deleting a bit).
(there may be problems with line breaks). Oh and final caveat, apart from
having figured out what folds i was comfortable with using some time in the
past, (and using that ever since) i can't claim to know much about vim folds.
Vim fold section follows:
" arch-tag: vimrc folds related ralph@amissah.com
:filetype on
:filetype indent on
set foldexpr=Foldexpr_fun('^\\i')
:hi FoldColumn ctermfg=Black ctermbg=magenta
:hi Folded ctermfg=Black ctermbg=magenta
"{{~foldsearchx FoldSearch (opens result of search all else closed)
"mapped to \f & \z t77 late
:set foldexpr=getline(v:lnum-1)!~@/&&getline(v:lnum)!~@/&&getline(v:lnum+1)!~@/
:map fs :set foldmethod=expr foldcolumn=2 foldlevel=0 <cr>
:map <leader>see :set foldmethod=expr foldcolumn=2 foldlevel=0 <cr>
:map <leader>fa :Fa<cr>
function! FoldInst()
if ( &filetype == "ruby" )
"erase folds, first fold then erase, or just use open folds zR
:map <leader>fe :R<cr> zE
:R
else
:map <leader>fe :F<cr> zE
:F
endif
endfunc
:nmap <silent> <leader>ff :silent call FoldInst()<cr>
:map <leader>fO :R <cr>fe<cr> " erase folds
"{{~foldtoggle Fold Toggle mapped to <space>
" Toggle fold state between closed and opened.
" If there is no fold at current line, just moves forward. If it is present,
" reverse it's state.
fun! ToggleFold()
if foldlevel('.') == 0
normal! l
else
if foldclosed('.') < 0
. foldclose
else
. foldopen
endif
endif
" Clear status line
echo
endfun
" Map this function to Space key.
:noremap <space> :call ToggleFold()<cr>
"{{~foldtype Fold? set foldtext
:set foldtext=v:folddashes.substitute(getline(v:foldstart),'{{\\d\\=','','g',)
:set foldexpr=getline(v:lnum-1)!~@/&&getline(v:lnum)!~@/&&getline(v:lnum+1)!~@/
"{{~foldsearch t77: Fold on search result
"(Fs <pattern> or Fc Frb Flm Fp) Fs pattern Fold search #Str (structure)
" ruby program pattern based on module class and def #Strlm (structure)
" lm file pattern based on <!1!> etc.
function! Foldsearch(search)
set fdm=manual
normal zE
normal G$
let folded = 0 "flag to set when a fold is found
let flags = "w" "allow wrapping in the search
let line1 = 0 "set marker for beginning of fold
while search(a:search, flags) > 0
let line2 = line(".")
" echo "pattern found at line # " line2
if (line2 -1 > line1)
: "echo line1 . ":" . (line2-1)
: "echo "A fold goes here."
: execute ":" . line1 . "," . (line2-1) . "fold"
: let folded = 1 "at least one fold has been found
: endif
: let line1 = line2 "update marker
: let flags = "W" "turn off wrapping
: endwhile
" Now create the last fold which goes to the end of the file.
: normal $G
: let line2 = line(".")
" echo "end of file found at line # " line2
: if (line2 > line1 && folded == 1)
" echo line1 . ":" . line2
" echo "A fold goes here."
: execute ":". line1 . "," . line2 . "fold"
: endif
: normal 1G
:endfunction
"{~folds Fold Patterns
"Command is executed as ':Fs pattern'"
:command! -nargs=+ -complete=command Fs call Foldsearch(<q-args>)
:command! -nargs=+ -complete=command Fold call Foldsearch(<q-args>)
"{{~folds :T Fold Patterns exuberant tag list :T
:command! T Fs ^\s*\S\+\s\+(
"{{~folds :R Fold Patterns Ruby :R
:command! R Fs \(^\s*\(\(def\|class\|module\)\s\)\|\
\(\(public\|protected\|private\)\(\s\|$\)\)\)\
\|^[0-9]{\|[#%"]\{1,4\}\s*{\({\|!!\)
:command! Re Fs \(^\s*\(\(def\|class\|module\)\s\)\)\
\|^\s*[ #%"0-9\~]\{0,4\}{\({{\|!!\)
"{{~folds :F Fold Patterns SiSU Markup :F
:command! F Fs [1-8]{\|#\s*{{\|^[#%"0-9]\{0,4\}\s*{[{!]
On Tue, 9 Nov 2004 10:58:01 +0900, Gavin Sinclair <gsinclair@soyabean.com.au> wrote:
On Tuesday, November 9, 2004, 12:47:07 PM, Gavin wrote:
On Tuesday, November 9, 2004, 12:43:34 PM, Ara wrote:
On Tue, 9 Nov 2004, Gavin Sinclair wrote:
Isn't there a way to limit the number of folds created by
fm=indent?yes - but you can say do THIS and THAT level. just a depth
Maybe the fm=syntax option, then? I don't know anything about that,
but it sounds promising.Follow-up: it's not promising. Vim's current syntax definition for
Ruby (http://vim-ruby.rubyforge.org) does enable syntax-based folding,
but it can't be selective about what it folds (i.e. classes and
methods only, per Ara's request).The following settings should be OK:
set foldmethod=syntax
set foldnestmax=2 " or 3If anyone knows enough about Vim to make the folding smarter for Ruby
files, please step forwardGavin