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

How to use fold-marker method with manpage sourcecode?

Expand Messages
  • Charlie Kester
    Hi vimmers, I m editing a fairly lengthy manpage, so I d like to be able to use vim folding to make the task easier. I d like to use fdm=fold-marker, to make
    Message 1 of 3 , Jan 26, 2013
    • 0 Attachment
      Hi vimmers,

      I'm editing a fairly lengthy manpage, so I'd like to be able to use vim
      folding to make the task easier.

      I'd like to use fdm=fold-marker, to make my folds persistent, but I
      can't figure out how to make this compatible with troff-style comments.

      If I select a set of lines and press zf, vim folds the lines and adds
      /*{{{*/ and /*}}}*/ to the first and last lines respectively (which were
      blank before the fold).

      For manpage code, I want that to be .\"{{{ and .\"}}}, since troff
      comments are lines beginning with dot backlash doublequote.

      Reading vim's online help for foldmarker, I see that I need to set
      commentstring. But what syntax should I use to specify the backslash
      and quote characters?

      I tried set commentstring=.\"
      and set commentstring=".\\\""
      and set commentstring='.\\\"'
      but none of these worked.

      There's probably an obvious solution here, but I'm not seeing it.



      --
      --
      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
    • Marcin Szamotulski
      ... Hi Charlie, This seems to work ... In the second example there are three backslashes since inside evaluates to a backslash and the third backslash is
      Message 2 of 3 , Jan 26, 2013
      • 0 Attachment
        On 16:41 Sat 26 Jan , Charlie Kester wrote:
        > Hi vimmers,
        >
        > I'm editing a fairly lengthy manpage, so I'd like to be able to use vim
        > folding to make the task easier.
        >
        > I'd like to use fdm=fold-marker, to make my folds persistent, but I
        > can't figure out how to make this compatible with troff-style comments.
        >
        > If I select a set of lines and press zf, vim folds the lines and adds
        > /*{{{*/ and /*}}}*/ to the first and last lines respectively (which were
        > blank before the fold).
        >
        > For manpage code, I want that to be .\"{{{ and .\"}}}, since troff
        > comments are lines beginning with dot backlash doublequote.
        >
        > Reading vim's online help for foldmarker, I see that I need to set
        > commentstring. But what syntax should I use to specify the backslash
        > and quote characters?
        >
        > I tried set commentstring=.\"
        > and set commentstring=".\\\""
        > and set commentstring='.\\\"'
        > but none of these worked.
        >
        > There's probably an obvious solution here, but I'm not seeing it.
        >
        >
        >
        > --
        > --
        > 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
        >
        >

        Hi Charlie,

        This seems to work
        :set cms=.\\\\"%s

        Or equivalently you can use this:

        :let &cms=".\\\"%s"

        or even better:

        :let &cms='.\"%s'

        In the second example there are three backslashes since \\ inside ""
        evaluates to a backslash and the third backslash is used to get ".
        While in '' strings you don't need to escape neither backslash nor the
        ". And you should not forget about the %s, which must be present.

        In the first examples there are four backslashes, which after being
        provided on the command line evaluate to just two backslashes which then
        are treated as in the second example. There is a section in the
        documentation: ":help option-backslash", I guess it is mentioned there.

        Best,
        Marcin

        --
        --
        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
      • Charlie Kester
        ... Nevermind, I finally saw my (obvious) mistake. It should be: set commentstring=. %s I forgot the %s. Added that and now zf works exactly as desired.
        Message 3 of 3 , Jan 26, 2013
        • 0 Attachment
          On 01/26/2013 04:41 PM, Charlie Kester wrote:
          > Hi vimmers,
          >
          > I'm editing a fairly lengthy manpage, so I'd like to be able to use vim
          > folding to make the task easier.
          >
          > I'd like to use fdm=fold-marker, to make my folds persistent, but I
          > can't figure out how to make this compatible with troff-style comments.
          >
          > If I select a set of lines and press zf, vim folds the lines and adds
          > /*{{{*/ and /*}}}*/ to the first and last lines respectively (which were
          > blank before the fold).
          >
          > For manpage code, I want that to be .\"{{{ and .\"}}}, since troff
          > comments are lines beginning with dot backlash doublequote.
          >
          > Reading vim's online help for foldmarker, I see that I need to set
          > commentstring. But what syntax should I use to specify the backslash and
          > quote characters?
          >
          > I tried set commentstring=.\"
          > and set commentstring=".\\\""
          > and set commentstring='.\\\"'
          > but none of these worked.
          >
          > There's probably an obvious solution here, but I'm not seeing it.
          >

          Nevermind, I finally saw my (obvious) mistake. It should be:

          set commentstring=.\\\"%s

          I forgot the %s. Added that and now zf works exactly as desired.

          Sorry for the noise, but at least the answer is out there in case some
          else makes the same mistake.

          --
          --
          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
        Your message has been successfully submitted and would be delivered to recipients shortly.