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

Re: formatlistpat escape \

Expand Messages
  • Ben Schmidt
    ... Because that s the way escaping works for the :set command. ... Makes use of single-quoted string and options in expressions. ... Ben. -- You received this
    Message 1 of 10 , Mar 3, 2011
    • 0 Attachment
      On 4/03/11 3:44 PM, Bee wrote:
      > Best viewed with a monospaced font.
      >
      > 'formatlistpat' 'flp' string (default: "^\s*\d\+[\]:.)}\t ]\s*")
      >
      > to get this:
      > ^\s*\(\d\|\a\)\+\.\s*
      >
      > must do this:
      > ^\\s*\\(\\d\\\|\\a\\)\\+\\.\\s*
      >
      > Why?

      Because that's the way escaping works for the :set command.

      > Is there a way to enter the string without escaping the "\" ?

      :let &flp='^\s*\(\d\|\a\)\+\.\s*'

      Makes use of single-quoted string and options in expressions.

      :help literal-string
      :help expr-option

      Ben.



      --
      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
    • Erik Christiansen
      ... Where might I read on how to emulate that super-nifty hierarchical ... Simply trying :set flp= ^ s* ( d | a ) + . s* just mashed everything
      Message 2 of 10 , Mar 15, 2011
      • 0 Attachment
        On Thu, Mar 03, 2011 at 08:44:37PM -0800, Bee wrote:
        >
        > 'formatlistpat' 'flp' string (default: "^\s*\d\+[\]:.)}\t ]\s*")
        ...
        > must do this:
        > ^\\s*\\(\\d\\\|\\a\\)\\+\\.\\s*
        ...
        > With :set tw=64 it works great as follows:

        Where might I read on how to emulate that super-nifty hierarchical
        numbered list indenting? i.e.:

        > 1. Lorem ipsum dolor sit amet, consectetur adipisicing:
        > a. Lorem ipsum dolor sit amet, consectetur adipisicing elit,
        > sed do eiusmod tempor incididunt ut labore et dolore
        > magna aliqua. Ut enim ad minim veniam, quis nostrud
        > exercitation ullamco. OR
        > b. Lorem ipsum dolor sit amet, consectetur adipisicing elit,
        > sed do eiusmod tempor incididunt ut labore et dolore
        > magna aliqua. Ut enim ad minim.
        > 2. Lorem ipsum dolor sit amet, consectetur adipisicing elit,
        > sed do eiusmod tempor incididunt ut labore et dolore magna
        > aliqua. Ut enim ad minim veniam, quis nostrud exercitation.


        Simply trying :set flp="^\\s*\\(\\d\\\|\\a\\)\\+\\.\\s*" just mashed
        everything together when I used gq}. The alternative single quoted
        shorter alternative did the same.

        The bit I'm missing isn't obvious from here. Any hints greatly
        appreciated.

        Erik

        --
        Abbott's Admonitions:
        (1) If you have to ask, you're not entitled to know.
        (2) If you don't like the answer, you shouldn't have asked the question.
        - Charles Abbot, dean, University of Virgini

        --
        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
      • Ben Schmidt
        ... You actually shouldn t include the double quotes when using the :set command. Try without them! ... (Untested.) Ben. -- You received this message from the
        Message 3 of 10 , Mar 15, 2011
        • 0 Attachment
          On 15/03/11 11:17 PM, Erik Christiansen wrote:
          > On Thu, Mar 03, 2011 at 08:44:37PM -0800, Bee wrote:
          >>
          >> 'formatlistpat' 'flp' string (default: "^\s*\d\+[\]:.)}\t ]\s*")
          > ...
          >> must do this:
          >> ^\\s*\\(\\d\\\|\\a\\)\\+\\.\\s*
          > ...
          >> With :set tw=64 it works great as follows:
          >
          > Where might I read on how to emulate that super-nifty hierarchical
          > numbered list indenting? i.e.:
          >
          >> 1. Lorem ipsum dolor sit amet, consectetur adipisicing:
          >> a. Lorem ipsum dolor sit amet, consectetur adipisicing elit,
          >> sed do eiusmod tempor incididunt ut labore et dolore
          >> magna aliqua. Ut enim ad minim veniam, quis nostrud
          >> exercitation ullamco. OR
          >> b. Lorem ipsum dolor sit amet, consectetur adipisicing elit,
          >> sed do eiusmod tempor incididunt ut labore et dolore
          >> magna aliqua. Ut enim ad minim.
          >> 2. Lorem ipsum dolor sit amet, consectetur adipisicing elit,
          >> sed do eiusmod tempor incididunt ut labore et dolore magna
          >> aliqua. Ut enim ad minim veniam, quis nostrud exercitation.
          >
          >
          > Simply trying :set flp="^\\s*\\(\\d\\\|\\a\\)\\+\\.\\s*" just mashed
          > everything together when I used gq}. The alternative single quoted
          > shorter alternative did the same.

          You actually shouldn't include the double quotes when using the :set
          command. Try without them!

          :set flp=^\\s*\\(\\d\\\|\\a\\)\\+\\.\\s*

          (Untested.)

          Ben.



          --
          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
        • Erik Christiansen
          ... Thanks. Trying that made no difference; gq} still collapsed all the numbered list text into a single paragraph. Erik -- You received this message from the
          Message 4 of 10 , Mar 15, 2011
          • 0 Attachment
            On Wed, Mar 16, 2011 at 12:14:26AM +1100, Ben Schmidt wrote:
            >
            > You actually shouldn't include the double quotes when using the :set
            > command. Try without them!
            >
            > :set flp=^\\s*\\(\\d\\\|\\a\\)\\+\\.\\s*
            >
            > (Untested.)

            Thanks. Trying that made no difference; gq} still collapsed all the
            numbered list text into a single paragraph.

            Erik

            --
            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
          • Ben Schmidt
            ... Do you have n in your formatoptions to enable numbered list formatting? ... Doing the set command from my last post, plus the one just above, makes it work
            Message 5 of 10 , Mar 15, 2011
            • 0 Attachment
              On 16/03/11 1:00 AM, Erik Christiansen wrote:
              > On Wed, Mar 16, 2011 at 12:14:26AM +1100, Ben Schmidt wrote:
              >>
              >> You actually shouldn't include the double quotes when using the :set
              >> command. Try without them!
              >>
              >> :set flp=^\\s*\\(\\d\\\|\\a\\)\\+\\.\\s*
              >>
              >> (Untested.)
              >
              > Thanks. Trying that made no difference; gq} still collapsed all the
              > numbered list text into a single paragraph.

              Do you have n in your formatoptions to enable numbered list formatting?

              :set fo+=n

              Doing the set command from my last post, plus the one just above, makes it work
              for me.

              Cheers,

              Ben.


              --
              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
            • Jürgen Krämer
              Hi, ... do you have the n flag included in you formatoptions setting? Regards, Jürgen -- Sometimes I think the surest sign that intelligent life exists
              Message 6 of 10 , Mar 15, 2011
              • 0 Attachment
                Hi,

                Erik Christiansen wrote:
                > On Wed, Mar 16, 2011 at 12:14:26AM +1100, Ben Schmidt wrote:
                >>
                >> You actually shouldn't include the double quotes when using the :set
                >> command. Try without them!
                >>
                >> :set flp=^\\s*\\(\\d\\\|\\a\\)\\+\\.\\s*
                >>
                >> (Untested.)
                >
                > Thanks. Trying that made no difference; gq} still collapsed all the
                > numbered list text into a single paragraph.

                do you have the "n" flag included in you 'formatoptions' setting?

                Regards,
                Jürgen


                --
                Sometimes I think the surest sign that intelligent life exists elsewhere
                in the universe is that none of it has tried to contact us. (Calvin)

                --
                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
              • ZyX
                Reply to message «Re: Reformatting numbered lists [Was: formatlistpat escape ]», sent 16:14:26 15 March 2011, Tuesday
                Message 7 of 10 , Mar 15, 2011
                • 0 Attachment
                  Reply to message «Re: Reformatting numbered lists [Was: formatlistpat escape
                  \]»,
                  sent 16:14:26 15 March 2011, Tuesday
                  by Ben Schmidt:

                  > You actually shouldn't include the double quotes when using the :set
                  > command. Try without them!
                  >
                  > :set flp=^\\s*\\(\\d\\\|\\a\\)\\+\\.\\s*
                  Or use let:
                  :let &flp='^\s*\(\d\|\a\)\+\.\s*'
                  : this does not require so much backslashes.

                  Original message:
                  > On 15/03/11 11:17 PM, Erik Christiansen wrote:
                  > > On Thu, Mar 03, 2011 at 08:44:37PM -0800, Bee wrote:
                  > >> 'formatlistpat' 'flp' string (default: "^\s*\d\+[\]:.)}\t ]\s*")
                  > >
                  > > ...
                  > >
                  > >> must do this:
                  > >> ^\\s*\\(\\d\\\|\\a\\)\\+\\.\\s*
                  > >
                  > > ...
                  > >
                  > >> With :set tw=64 it works great as follows:
                  > > Where might I read on how to emulate that super-nifty hierarchical
                  > >
                  > > numbered list indenting? i.e.:
                  > >> 1. Lorem ipsum dolor sit amet, consectetur adipisicing:
                  > >> a. Lorem ipsum dolor sit amet, consectetur adipisicing elit,
                  > >>
                  > >> sed do eiusmod tempor incididunt ut labore et dolore
                  > >> magna aliqua. Ut enim ad minim veniam, quis nostrud
                  > >> exercitation ullamco. OR
                  > >>
                  > >> b. Lorem ipsum dolor sit amet, consectetur adipisicing elit,
                  > >>
                  > >> sed do eiusmod tempor incididunt ut labore et dolore
                  > >> magna aliqua. Ut enim ad minim.
                  > >>
                  > >> 2. Lorem ipsum dolor sit amet, consectetur adipisicing elit,
                  > >>
                  > >> sed do eiusmod tempor incididunt ut labore et dolore magna
                  > >> aliqua. Ut enim ad minim veniam, quis nostrud exercitation.
                  > >
                  > > Simply trying :set flp="^\\s*\\(\\d\\\|\\a\\)\\+\\.\\s*" just mashed
                  > > everything together when I used gq}. The alternative single quoted
                  > > shorter alternative did the same.
                  >
                  > You actually shouldn't include the double quotes when using the :set
                  > command. Try without them!
                  >
                  > :set flp=^\\s*\\(\\d\\\|\\a\\)\\+\\.\\s*
                  >
                  > (Untested.)
                  >
                  > Ben.
                • Erik Christiansen
                  ... Doh, I haven t fiddled with formatoptions for many years. Adding n , and deleting 2 , did the trick. I ll try to fly for a while without 2 , but will
                  Message 8 of 10 , Mar 16, 2011
                  • 0 Attachment
                    On Wed, Mar 16, 2011 at 01:12:03AM +1100, Ben Schmidt wrote:
                    >
                    > Do you have n in your formatoptions to enable numbered list formatting?
                    >
                    > :set fo+=n
                    >
                    > Doing the set command from my last post, plus the one just above, makes
                    > it work for me.

                    Doh, I haven't fiddled with formatoptions for many years.
                    Adding 'n', and deleting '2', did the trick.

                    I'll try to fly for a while without '2', but will have to change my
                    habits for it to (potentially) work. If it doesn't, I suppose I could
                    try modelines or au, to fudge my way to a working compromise.

                    Many thanks for the guidance. I've (intermittently) wished for years
                    that vim could handle numbered lists, not realising where the weak link
                    lay. ;-)

                    Erik

                    --
                    Miracle! It works!
                    Once again, to fix the bug change the operator!
                    - Emmanuel, on mutt ML

                    --
                    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
                  • Bee
                    On Mar 16, 12:02 am, Erik Christiansen ... Create two mappings to switch: map fon :set fo-=2 fo+=n map fo2 :set
                    Message 9 of 10 , Mar 16, 2011
                    • 0 Attachment
                      On Mar 16, 12:02 am, Erik Christiansen <dva...@...>
                      wrote:
                      > On Wed, Mar 16, 2011 at 01:12:03AM +1100, Ben Schmidt wrote:
                      >
                      > > Do you have n in your formatoptions to enable numbered list formatting?
                      >
                      > >    :set fo+=n
                      >
                      > > Doing the set command from my last post, plus the one just above, makes
                      > > it work for me.
                      >
                      > Doh, I haven't fiddled with formatoptions for many years.
                      > Adding 'n', and deleting '2', did the trick.
                      >
                      > I'll try to fly for a while without '2', but will have to change my
                      > habits for it to (potentially) work. If it doesn't, I suppose I could
                      > try modelines or au, to fudge my way to a working compromise.

                      Create two mappings to switch:

                      map <Leader>fon :set fo-=2 fo+=n<cr>
                      map <Leader>fo2 :set fo-=n fo+=2<cr>

                      Or one to toggle:

                      function! Foo()
                      if &fo =~ "2"
                      set fo-=2 fo+=n
                      else
                      set fo-=n fo+=2
                      endif
                      endfun
                      map <Leader>foo :call Foo()<cr>

                      -Bill

                      --
                      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.