Saturday, May 21, 2011

Re: Hide comments without remove?

I have found this command to hide comments (here http://www.linuxquestions.org/questions/linux-software-2/vim-foldmarker-with-multiple-options-512939/)

nmap <silent> <F10> :call FoldComments() <CR>
let s:fold_comments = 0
function! FoldComments()
  set foldmethod=syntax
  if (s:fold_comments == 0)
    let s:fold_comments = 1
    set foldlevel=0
    echo "Folding comments"
  else
    let s:fold_comments = 0
    set foldlevel=9
    echo "Unfolding comments"
  endif
  set foldmethod=manual
endfunction

Taking the example of C++ comments folding:
If I have something like this:
//
//

code

//
code


I would like to obtain this:
+
code
+
code

But I obtain this (all folded):
+

Any suggestion?

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: