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

Re: hiding comments

Expand Messages
  • Wind
    Hello David, ... Let me know if I missed something: I have little knowledge about Python. Tuesday, February 1, 2005, 3:32:45 AM, you wrote: DS I would like to
    Message 1 of 6 , Jan 31, 2005
    • 0 Attachment
      Hello David,
      try this:
      :sy region myFold start="^#@" skip="^#@" end="^\(#@\)\@!" fold transparent contains=ALLBUT,myFold

      Let me know if I missed something: I have little knowledge about Python.

      Tuesday, February 1, 2005, 3:32:45 AM, you wrote:

      DS> I would like to cause comment blocks in Python code to be folded away
      DS> (or use some similar mechanism) independently of like indented,
      DS> non-comment lines.

      DS> In particular, I am using Vim with the outlining tool, Leo, which places
      DS> marker lines in Python code files that start with '#@'. I would like to
      DS> treat those blocks as deeply folded block since I never need to see it.
      DS> But I can't seem to get folding to think take care of those comment
      DS> lines and subsequently the rest of the Python file.

      DS> In this snippet, I would like to treat lines 1 and 2 as a single,
      DS> independent, block to be folded:

      DS> 1 #@mark some section
      DS> 2 #@<<vim plugin>>
      DS> 4 #I hope I can read this comment even
      DS> 5 #when the previous lines are folded
      DS> 5 def open_in_vim():
      DS> 6 open_best_editor('Vim')

      DS> Any direction is appreciated.

      DS> David S.



      --
      Best regards,
      Wind mailto:sonic_wind@...
    • Vigil
      I adapted this for /* */ comments and it works when I type it in manually, but it seems to be ignored when I put it in vimrc. What could I be doing wrong? sy
      Message 2 of 6 , Feb 1, 2005
      • 0 Attachment
        I adapted this for /* */ comments and it works when I type it in manually,
        but it seems to be ignored when I put it in vimrc. What could I be doing
        wrong?

        sy region myfold start="^/\*" end="\*/$" fold transparent contains=ALLBUT,myfold

        Cheers.

        On Tue, 1 Feb 2005, Wind sonic_wind-at-tut.by |Vim| wrote:

        > Hello David,
        > try this:
        > :sy region myFold start="^#@" skip="^#@" end="^\(#@\)\@!" fold transparent
        >contains=ALLBUT,myFold
        >
        > Let me know if I missed something: I have little knowledge about Python.
        >
        > Tuesday, February 1, 2005, 3:32:45 AM, you wrote:
        >
        > DS> I would like to cause comment blocks in Python code to be folded away
        > DS> (or use some similar mechanism) independently of like indented,
        > DS> non-comment lines.
        >
        > DS> In particular, I am using Vim with the outlining tool, Leo, which places
        > DS> marker lines in Python code files that start with '#@'. I would like to
        > DS> treat those blocks as deeply folded block since I never need to see it.
        > DS> But I can't seem to get folding to think take care of those comment
        > DS> lines and subsequently the rest of the Python file.
        >
        > DS> In this snippet, I would like to treat lines 1 and 2 as a single,
        > DS> independent, block to be folded:
        >
        > DS> 1 #@mark some section
        > DS> 2 #@<<vim plugin>>
        > DS> 4 #I hope I can read this comment even
        > DS> 5 #when the previous lines are folded
        > DS> 5 def open_in_vim():
        > DS> 6 open_best_editor('Vim')
        >
        > DS> Any direction is appreciated.
        >
        > DS> David S.
        >
        >
        >
        >

        --

        .
      • Wind
        Hello Vigil, it doesn t work becaus when you load a bufer with known filetype syntax script for this filetype is executed (and almost any of them have :syntax
        Message 3 of 6 , Feb 1, 2005
        • 0 Attachment
          Hello Vigil,
          it doesn't work becaus when you load a bufer with known filetype
          syntax script for this filetype is executed (and almost any of them
          have ":syntax clear" command in the beginning, so your command have no
          efect in this situation.
          Usually I copy the syntax file to local syntax directory
          (~/.vim/syntax - for Unix) and add syntax elements I want to it. This
          way it works.

          And about your command I suppse it is something C-like, so I think
          it is usful to look in to the appropriate syntax file. I think
          there is such description of the comment region, so simply add
          "fold" attribute to it otherwise I think you can use more simple
          command:
          :sy region myfold start="/\*" end="\*/" fold transparent

          I think that the language syntax permits start of the comment at
          any position in the line, so "^" in the start expresson is
          incorrect. Also with end expression.

          attribute "contains=ALLBUT,myfold" simply says that there is no myfold subregions
          In C-like languages nested comments are not allowd I think(Or
          simply don't use), and in the example with Python it allows not to
          fold every line (try to delete the attribute and you will see what
          i mean).


          Tuesday, February 1, 2005, 1:33:16 PM, you wrote:

          V> I adapted this for /* */ comments and it works when I type it in manually,
          V> but it seems to be ignored when I put it in vimrc. What could I be doing
          V> wrong?

          V> sy region myfold start="^/\*" end="\*/$" fold transparent contains=ALLBUT,myfold

          V> Cheers.

          V> On Tue, 1 Feb 2005, Wind sonic_wind-at-tut.by |Vim| wrote:

          >> Hello David,
          >> try this:
          >> :sy region myFold start="^#@" skip="^#@" end="^\(#@\)\@!" fold transparent
          >>contains=ALLBUT,myFold
          >>
          >> Let me know if I missed something: I have little knowledge about Python.
          >>
          >> Tuesday, February 1, 2005, 3:32:45 AM, you wrote:
          >>
          >> DS> I would like to cause comment blocks in Python code to be folded away
          >> DS> (or use some similar mechanism) independently of like indented,
          >> DS> non-comment lines.
          >>
          >> DS> In particular, I am using Vim with the outlining tool, Leo, which places
          >> DS> marker lines in Python code files that start with '#@'. I would like to
          >> DS> treat those blocks as deeply folded block since I never need to see it.
          >> DS> But I can't seem to get folding to think take care of those comment
          >> DS> lines and subsequently the rest of the Python file.
          >>
          >> DS> In this snippet, I would like to treat lines 1 and 2 as a single,
          >> DS> independent, block to be folded:
          >>
          >> DS> 1 #@mark some section
          >> DS> 2 #@<<vim plugin>>
          >> DS> 4 #I hope I can read this comment even
          >> DS> 5 #when the previous lines are folded
          >> DS> 5 def open_in_vim():
          >> DS> 6 open_best_editor('Vim')
          >>
          >> DS> Any direction is appreciated.
          >>
          >> DS> David S.
          >>
          >>
          >>
          >>




          --
          Best regards,
          Wind mailto:sonic_wind@...
        • David S.
          So I did not have any luck using this approach. In fact I could not actually get that to work at all. I tried to add it to my python_folds.vim file. I also
          Message 4 of 6 , Feb 1, 2005
          • 0 Attachment
            So I did not have any luck using this approach. In fact I could not
            actually get that to work at all.

            I tried to add it to my python_folds.vim file. I also tried
            :syntax clear
            :sy region myFold start="^#@" skip="^#@" end="^\(#@\)\@!" fold
            transparent contains=ALLBUT,myFold #all one line of course
            :set foldmethod=syntax

            The only partial solution I have is to just use:
            :set foldmethod=expr
            :set foldexpr=getline(v:lnum)=~'^\s*#@'

            This folds away the particular comment lines I want to ignore, but of
            course, now I do not have the rest of the Python folding.

            Thanks for your help.

            David S.


            Wind wrote:
            > Hello David,
            > try this:
            > :sy region myFold start="^#@" skip="^#@" end="^\(#@\)\@!" fold transparent contains=ALLBUT,myFold
            >
            > Let me know if I missed something: I have little knowledge about Python.
            >
            > Tuesday, February 1, 2005, 3:32:45 AM, you wrote:
            >
            > DS> I would like to cause comment blocks in Python code to be folded away
            > DS> (or use some similar mechanism) independently of like indented,
            > DS> non-comment lines.
            >
            > DS> In particular, I am using Vim with the outlining tool, Leo, which places
            > DS> marker lines in Python code files that start with '#@'. I would like to
            > DS> treat those blocks as deeply folded block since I never need to see it.
            > DS> But I can't seem to get folding to think take care of those comment
            > DS> lines and subsequently the rest of the Python file.
            >
            > DS> In this snippet, I would like to treat lines 1 and 2 as a single,
            > DS> independent, block to be folded:
            >
            > DS> 1 #@mark some section
            > DS> 2 #@<<vim plugin>>
            > DS> 4 #I hope I can read this comment even
            > DS> 5 #when the previous lines are folded
            > DS> 5 def open_in_vim():
            > DS> 6 open_best_editor('Vim')
            >
            > DS> Any direction is appreciated.
            >
            > DS> David S.
            >
            >
            >
          • Wind
            Hello David, Tuesday, February 1, 2005, 6:19:42 PM, you wrote: DS So I did not have any luck using this approach. In fact I could not DS actually get that
            Message 5 of 6 , Feb 1, 2005
            • 0 Attachment
              Hello David,

              Tuesday, February 1, 2005, 6:19:42 PM, you wrote:

              DS> So I did not have any luck using this approach. In fact I could not
              DS> actually get that to work at all.

              DS> I tried to add it to my python_folds.vim file. I also tried
              DS> :syntax clear
              DS> :sy region myFold start="^#@" skip="^#@" end="^\(#@\)\@!" fold
              So if "#@" thing can stand few white spaces out of the line
              beginning substitute for "\s*#@" as you do in your solution I
              think it will work.
              :sy region myFold start="^\s*#@" skip="^\s*#@" end="^\s*\(#@\)\@!" fold transparent contains=ALLBUT,myFold
              DS> transparent contains=ALLBUT,myFold #all one line of course
              DS> :set foldmethod=syntax

              DS> The only partial solution I have is to just use:
              DS> :set foldmethod=expr
              DS> :set foldexpr=getline(v:lnum)=~'^\s*#@'

              DS> This folds away the particular comment lines I want to ignore, but of
              DS> course, now I do not have the rest of the Python folding.

              DS> Thanks for your help.

              DS> David S.


              DS> Wind wrote:
              >> Hello David,
              >> try this:
              >> :sy region myFold start="^#@" skip="^#@" end="^\(#@\)\@!" fold
              >> transparent contains=ALLBUT,myFold
              >>
              >> Let me know if I missed something: I have little knowledge about Python.
              >>
              >> Tuesday, February 1, 2005, 3:32:45 AM, you wrote:
              >>
              >> DS> I would like to cause comment blocks in Python code to be folded away
              >> DS> (or use some similar mechanism) independently of like indented,
              >> DS> non-comment lines.
              >>
              >> DS> In particular, I am using Vim with the outlining tool, Leo, which places
              >> DS> marker lines in Python code files that start with '#@'. I would like to
              >> DS> treat those blocks as deeply folded block since I never need to see it.
              >> DS> But I can't seem to get folding to think take care of those comment
              >> DS> lines and subsequently the rest of the Python file.
              >>
              >> DS> In this snippet, I would like to treat lines 1 and 2 as a single,
              >> DS> independent, block to be folded:
              >>
              >> DS> 1 #@mark some section
              >> DS> 2 #@<<vim plugin>>
              >> DS> 4 #I hope I can read this comment even
              >> DS> 5 #when the previous lines are folded
              >> DS> 5 def open_in_vim():
              >> DS> 6 open_best_editor('Vim')
              >>
              >> DS> Any direction is appreciated.
              >>
              >> DS> David S.
              >>
              >>
              >>



              --
              Best regards,
              Wind mailto:sonic_wind@...
            Your message has been successfully submitted and would be delivered to recipients shortly.