Loading ...
Sorry, an error occurred while loading the content.

86160Re: Simple hiding all comments by folding

Expand Messages
  • Charles E. Campbell, Jr.
    Dec 31, 2007
      arctgx wrote:

      >Is there a simple universal command which hides all comments in file
      >by current syntax? I would like, for example hide comments in my shell
      >scripts (syntax=sh) or xorg.conf (syntax=xf86conf). There is a lot
      >text about folding but I still can't find a good solution.
      >I tried
      >set foldmarker=#,$ | set foldmethod=marker
      >but it is not universal solution and... hides all lines of shell
      >script ;) ($ doesn't denote end of line?)

      Inline comments can't be folded away; at least, not without Vince
      Negri's "conceal" patch to vim. Others have already made suggestions
      about folding markers, so I won't repeat that. One thing you could do
      instead is to highlight-link comments to something like Ignore and then
      back to Comment. For example, *.sh scripts' comments are shComment, so
      you could use (untested) something like:

      map <f1> if !exists("cmmnt_toggle")<bar><bar>cmmnt_toggle == 0<bar>let
      cmmnt_toggle=1<bar>hi link shComment Ignore<bar>else<bar>let
      cmmnt_toggle= 0<bar>hi link shComment Comment<bar>endif<cr>

      to toggle between normally highlighted comments and "Ignore"'d comments.

      Chip Campbell

      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
    • Show all 17 messages in this topic