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

Re: regex variable

Expand Messages
  • Marcin Szamotulski
    ... Hi, ... and then use: /^r=ip (i.i. hit / for search, the CTRL+r, then =, then write the variable name and then hit ). See :help c^r= for the
    Message 1 of 23 , Jul 18 6:55 AM
    • 0 Attachment
      On 09:42 Thu 18 Jul , shawn wilson wrote:
      > Is there a way of using a variable in a regex?
      >
      > I'm constantly looking for the first octet of IP addresses, so I do:
      > /[^0-9\.]10\.
      >
      > What I've been doing is hitting / and up arrow and then edit but if I
      > could store [^0-9\.] in something easily accessed, that would save
      > some time.

      Hi,

      You can set:
      :let ip='[^0-9\.]
      and then use:
      /^r=ip<cr>
      (i.i. hit '/' for search, the CTRL+r, then =, then write the variable name and
      then hit <cr>). See ":help c^r=" for the expression register.

      But maybe more useful is make a mapping:
      cmap <Leader>i ['0-9\.]

      or even better allow for this map only in search:
      cmap <expr> <Leader>i (getcmdtype() == '/' ? "['0-9\\.]" : '\i')

      I assumed here that your <Leader> key is set to '\', otherwise you just
      have to modify the '\i'.

      Best regards,
      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

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • shawn wilson
      On Thu, Jul 18, 2013 at 9:50 AM, Gautier DI FOLCO ... Uh, I guess I wasn t clear - I have no issues writing regexes - the goal is to stop typing the same thing
      Message 2 of 23 , Jul 18 6:58 AM
      • 0 Attachment
        On Thu, Jul 18, 2013 at 9:50 AM, Gautier DI FOLCO
        <gautier.difolco@...> wrote:
        > 2013/7/18 shawn wilson <ag4ve.us@...>

        >> What I've been doing is hitting / and up arrow and then edit but if I
        >> could store [^0-9\.] in something easily accessed, that would save
        >> some time.
        >

        >
        > for example:
        > :%s/\([^0-9\.]\)10\./\1/g
        >

        Uh, I guess I wasn't clear - I have no issues writing regexes - the
        goal is to stop typing the same thing over and over again. I figure
        maybe there's a way to access variables within the interpreter or
        match() or maybe run a macro within one of them.

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

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • shawn wilson
        Sweet, didn t know about C+r - that works. I ll look more into the leader stuff (which ll probably work better) later. Thanks ... -- -- You received this
        Message 3 of 23 , Jul 18 7:06 AM
        • 0 Attachment
          Sweet, didn't know about C+r - that works. I'll look more into the
          leader stuff (which'll probably work better) later. Thanks

          On Thu, Jul 18, 2013 at 9:55 AM, Marcin Szamotulski <mszamot@...> wrote:
          > On 09:42 Thu 18 Jul , shawn wilson wrote:
          >> Is there a way of using a variable in a regex?
          >>
          >> I'm constantly looking for the first octet of IP addresses, so I do:
          >> /[^0-9\.]10\.
          >>
          >> What I've been doing is hitting / and up arrow and then edit but if I
          >> could store [^0-9\.] in something easily accessed, that would save
          >> some time.
          >
          > Hi,
          >
          > You can set:
          > :let ip='[^0-9\.]
          > and then use:
          > /^r=ip<cr>
          > (i.i. hit '/' for search, the CTRL+r, then =, then write the variable name and
          > then hit <cr>). See ":help c^r=" for the expression register.
          >
          > But maybe more useful is make a mapping:
          > cmap <Leader>i ['0-9\.]
          >
          > or even better allow for this map only in search:
          > cmap <expr> <Leader>i (getcmdtype() == '/' ? "['0-9\\.]" : '\i')
          >
          > I assumed here that your <Leader> key is set to '\', otherwise you just
          > have to modify the '\i'.
          >
          > Best regards,
          > 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
          >
          > ---
          > You received this message because you are subscribed to the Google Groups "vim_use" group.
          > To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          > For more options, visit https://groups.google.com/groups/opt_out.
          >
          >

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

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Marcin Szamotulski
          ... As written in the above list header added to every message, please do not top-post. Bottom-posting is much nicer for people who want to follow a thread
          Message 4 of 23 , Jul 18 8:09 AM
          • 0 Attachment
            On 10:06 Thu 18 Jul , shawn wilson wrote:
            > Sweet, didn't know about C+r - that works. I'll look more into the
            > leader stuff (which'll probably work better) later. Thanks
            > > --
            > > --
            > > 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
            > >
            > > ---
            > > You received this message because you are subscribed to the Google Groups "vim_use" group.
            > > To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            > > For more options, visit https://groups.google.com/groups/opt_out.
            > >
            > >

            As written in the above list header added to every message, please do
            not top-post. Bottom-posting is much nicer for people who want to
            follow a thread discussion.

            Regards,
            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

            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          • Bee
            ... List recent searches, allowing you to select one, and if need edit. Similarly :help q: List recent commands. Bill -- -- You received this message from the
            Message 5 of 23 , Jul 18 8:28 AM
            • 0 Attachment
              On Thursday, July 18, 2013 6:42:06 AM UTC-7, shawn wilson wrote:
              > Is there a way of using a variable in a regex?
              >
              >
              >
              > I'm constantly looking for the first octet of IP addresses, so I do:
              >
              > /[^0-9\.]10\.
              >
              >
              >
              > What I've been doing is hitting / and up arrow and then edit but if I
              >
              > could store [^0-9\.] in something easily accessed, that would save
              >
              > some time.

              Different approach:

              :help q/

              List recent searches, allowing you to select one, and if need edit.

              Similarly :help q:

              List recent commands.

              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

              ---
              You received this message because you are subscribed to the Google Groups "vim_use" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • Lech Lorens
              ... Slightly off-topic, but wanted to make you aware that [^ .] matches anything that isn t a dot AND IS NOT A BACKSLASH. IOW backslash is not escaping the dot
              Message 6 of 23 , Jul 18 1:51 PM
              • 0 Attachment
                On Thursday, July 18, 2013 3:42:06 PM UTC+2, shawn wilson wrote:
                > Is there a way of using a variable in a regex?
                >
                > I'm constantly looking for the first octet of IP addresses, so I do:
                > /[^0-9\.]10\.
                >
                >
                >
                > What I've been doing is hitting / and up arrow and then edit but if I
                > could store [^0-9\.] in something easily accessed, that would save
                > some time.

                Slightly off-topic, but wanted to make you aware that [^\.] matches anything that isn't a dot AND IS NOT A BACKSLASH. IOW backslash is not escaping the dot inside the [] range.

                Cheers,
                Lech

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

                ---
                You received this message because you are subscribed to the Google Groups "vim_use" group.
                To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                For more options, visit https://groups.google.com/groups/opt_out.
              • Ben Fritz
                ... And furthermore the . doesn t NEED escaping inside the [] range. -- -- You received this message from the vim_use maillist. Do not top-post! Type your
                Message 7 of 23 , Jul 18 2:54 PM
                • 0 Attachment
                  On Thursday, July 18, 2013 3:51:01 PM UTC-5, Lech Lorens wrote:
                  > On Thursday, July 18, 2013 3:42:06 PM UTC+2, shawn wilson wrote:
                  > >
                  > > I'm constantly looking for the first octet of IP addresses, so I do:
                  > > /[^0-9\.]10\.
                  > >
                  >
                  > Slightly off-topic, but wanted to make you aware that [^\.] matches anything that isn't a dot AND IS NOT A BACKSLASH. IOW backslash is not escaping the dot inside the [] range.
                  >

                  And furthermore the . doesn't NEED escaping inside the [] range.

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

                  ---
                  You received this message because you are subscribed to the Google Groups "vim_use" group.
                  To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                  For more options, visit https://groups.google.com/groups/opt_out.
                • shawn wilson
                  ... anything that isn t a dot AND IS NOT A BACKSLASH. IOW backslash is not escaping the dot inside the [] range. ... This is probably a feature request but I
                  Message 8 of 23 , Jul 18 6:34 PM
                  • 0 Attachment


                    On Jul 18, 2013 5:54 PM, "Ben Fritz" <fritzophrenic@...> wrote:
                    >
                    > On Thursday, July 18, 2013 3:51:01 PM UTC-5, Lech Lorens wrote:
                    > > On Thursday, July 18, 2013 3:42:06 PM UTC+2, shawn wilson wrote:
                    > > >
                    > > > I'm constantly looking for the first octet of IP addresses, so I do:
                    > > > /[^0-9\.]10\.
                    > > >
                    > >
                    > > Slightly off-topic, but wanted to make you aware that [^\.] matches anything that isn't a dot AND IS NOT A BACKSLASH. IOW backslash is not escaping the dot inside the [] range.
                    > >
                    >
                    > And furthermore the . doesn't NEED escaping inside the [] range.
                    >

                    This is probably a feature request but I really do hate the regex engine and would love to swap it out. Is there / can there be a compile time option to use a different engine?

                    --
                    --
                    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
                     
                    ---
                    You received this message because you are subscribed to the Google Groups "vim_use" group.
                    To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                    For more options, visit https://groups.google.com/groups/opt_out.
                     
                     
                  • Tony Mechelynck
                    ... There is a runtime option to disable the new engine in favour of the old one ù or vice-versa. See :help regexpengine -- The only difference in the game
                    Message 9 of 23 , Jul 18 7:10 PM
                    • 0 Attachment
                      On 07/19/13 03:34, shawn wilson wrote:
                      >
                      > On Jul 18, 2013 5:54 PM, "Ben Fritz" <fritzophrenic@...
                      > <mailto:fritzophrenic@...>> wrote:
                      > >
                      > > On Thursday, July 18, 2013 3:51:01 PM UTC-5, Lech Lorens wrote:
                      > > > On Thursday, July 18, 2013 3:42:06 PM UTC+2, shawn wilson wrote:
                      > > > >
                      > > > > I'm constantly looking for the first octet of IP addresses, so I do:
                      > > > > /[^0-9\.]10\.
                      > > > >
                      > > >
                      > > > Slightly off-topic, but wanted to make you aware that [^\.] matches
                      > anything that isn't a dot AND IS NOT A BACKSLASH. IOW backslash is not
                      > escaping the dot inside the [] range.
                      > > >
                      > >
                      > > And furthermore the . doesn't NEED escaping inside the [] range.
                      > >
                      >
                      > This is probably a feature request but I really do hate the regex engine
                      > and would love to swap it out. Is there / can there be a compile time
                      > option to use a different engine?

                      There is a runtime option to disable the new engine in favour of the old
                      one — or vice-versa. See :help 'regexpengine'

                      --
                      The only difference in the game of love over the last few thousand years
                      is that they've changed trumps from clubs to diamonds.
                      -- The Indianapolis Star

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

                      ---
                      You received this message because you are subscribed to the Google Groups "vim_use" group.
                      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                      For more options, visit https://groups.google.com/groups/opt_out.
                    • John Beckett
                      ... No (I assume you want different regex syntax, probably PCRE). Tony s post is talking about a new Vim regex engine intended to be fully compatible with the
                      Message 10 of 23 , Jul 18 8:48 PM
                      • 0 Attachment
                        shawn wilson wrote:
                        > This is probably a feature request but I really do hate the
                        > regex engine and would love to swap it out. Is there / can
                        > there be a compile time option to use a different engine?

                        No (I assume you want different regex syntax, probably PCRE).

                        Tony's post is talking about a new Vim regex engine intended to
                        be fully compatible with the old syntax, but faster.

                        Like Vim's scripting language, Vim's regex syntax makes a lot of
                        sense for editing text because they provide procedures that
                        often work in an optimum way.

                        John


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

                        ---
                        You received this message because you are subscribed to the Google Groups "vim_use" group.
                        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                        For more options, visit https://groups.google.com/groups/opt_out.
                      • shawn wilson
                        ... libpcre would be fine, yes. Or the library that Ruby uses - either way. ... Though this means there s already code for choosing between engines which is
                        Message 11 of 23 , Jul 19 12:59 AM
                        • 0 Attachment


                          On Jul 18, 2013 11:48 PM, "John Beckett" <johnb.beckett@...> wrote:
                          >
                          > shawn wilson wrote:
                          > > This is probably a feature request but I really do hate the
                          > > regex engine and would love to swap it out. Is there / can
                          > > there be a compile time option to use a different engine?
                          >
                          > No (I assume you want different regex syntax, probably PCRE).
                          >

                          libpcre would be fine, yes. Or the library that Ruby uses - either way.

                          > Tony's post is talking about a new Vim regex engine intended to
                          > be fully compatible with the old syntax, but faster.
                          >

                          Though this means there's already code for choosing between engines which is good.

                          > Like Vim's scripting language, Vim's regex syntax makes a lot of
                          > sense for editing text because they provide procedures that
                          > often work in an optimum way.
                          >

                          Yeah, it looks like sed's syntax. If I'm used to writing things one way (say in code) and then hit '/' to do a similar thing inside my editor, switching mindset constantly makes me loose my thought (generally what happens) or make stupid errors like earlier in this thread.

                          I guess this should be a feature request then?

                          --
                          --
                          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
                           
                          ---
                          You received this message because you are subscribed to the Google Groups "vim_use" group.
                          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                          For more options, visit https://groups.google.com/groups/opt_out.
                           
                           
                        • John Beckett
                          ... Vim is strongly attached to compatibility, and is immensely complex. I would not bother requesting a new regex syntax because it won t happen. John -- --
                          Message 12 of 23 , Jul 19 3:02 AM
                          • 0 Attachment
                            shawn wilson wrote:
                            > libpcre would be fine, yes. Or the library that Ruby uses -
                            > either way.
                            > ...
                            > I guess this should be a feature request then?

                            Vim is strongly attached to compatibility, and is immensely
                            complex. I would not bother requesting a new regex syntax
                            because it won't happen.

                            John


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

                            ---
                            You received this message because you are subscribed to the Google Groups "vim_use" group.
                            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                            For more options, visit https://groups.google.com/groups/opt_out.
                          • Erik Christiansen
                            ... Granted, vim s obscurely parochial regex engine has for many years been the one great failing in an otherwise stunningly good utility. But now it has the
                            Message 13 of 23 , Jul 19 3:57 AM
                            • 0 Attachment
                              On 18.07.13 21:34, shawn wilson wrote:
                              > This is probably a feature request but I really do hate the regex engine
                              > and would love to swap it out. Is there / can there be a compile time
                              > option to use a different engine?

                              Granted, vim's obscurely parochial regex engine has for many years been
                              the one great failing in an otherwise stunningly good utility. But now
                              it has the \v regex prefix to provide a very good simulation of posix
                              EREs, qualifying that mode as "modern regex"¹.

                              It does seem ludicrous to be afflicted by a different regex dialect in
                              each tool one uses, especially when awk, mutt, egrep (or grep -E), sed
                              -r, vim with the \v prefix, lex (OK, it also has extensions), and other
                              *nix tools _all_ use modern posix EREs, allowing users to move
                              seamlessly between them, without incurring a brain hernia. EREs also
                              don't suffer from the backslash storm which afflicts obsolete REs.

                              Is there anything additional about vim's regex engine which troubles you?

                              Does the new regex engine not address any of those concerns?
                              (I freely admit to not having tried it myself yet, so cannot say what
                              benefits it might have brought.)

                              Incidentally, a number of years ago, I compiled vim with another regex
                              suite, and the resulting EREs worked beautifully - except that vim's
                              help broke. In retrospect, I guess that new helptags might have fixed
                              that. In any event, roll-your-own-regex-suite didn't take long, AFAIR,
                              comprising mainly some wrapper functions to handle the slightly
                              different function interface.

                              Erik

                              ¹ See `man 7 regex`

                              --
                              "I am sorry for the length of this letter, but I did not have the time
                              to write a short one"
                              - Blaise Pascal (in 1657), and later, Mark Twain.

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

                              ---
                              You received this message because you are subscribed to the Google Groups "vim_use" group.
                              To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                              For more options, visit https://groups.google.com/groups/opt_out.
                            • BPJ
                              ... I feel the same sometimes, as I code Perl in Vim on a daily basis, but Vim s (old) regex engine/syntax actually allows useful things which are impossible
                              Message 14 of 23 , Jul 19 6:49 AM
                              • 0 Attachment
                                2013-07-19 09:59, shawn wilson skrev:
                                > On Jul 18, 2013 11:48 PM, "John Beckett" <johnb.beckett@...> wrote:
                                >>
                                >> shawn wilson wrote:
                                >>> This is probably a feature request but I really do hate the
                                >>> regex engine and would love to swap it out. Is there / can
                                >>> there be a compile time option to use a different engine?
                                >>
                                >> No (I assume you want different regex syntax, probably PCRE).
                                >>
                                >
                                > libpcre would be fine, yes. Or the library that Ruby uses - either way.

                                > Yeah, it looks like sed's syntax. If I'm used to writing things one way
                                > (say in code) and then hit '/' to do a similar thing inside my editor,
                                > switching mindset constantly makes me loose my thought (generally what
                                > happens) or make stupid errors like earlier in this thread.

                                I feel the same sometimes, as I code Perl in Vim on a daily
                                basis, but Vim's (old) regex engine/syntax actually allows useful
                                things which are impossible or hard inn Perl, not only the other
                                way around. And I can always filter through a perl oneliner if I
                                want to use perl's regex engine. Can't you do the same with Ruby?
                                Vim regexes come closer to Perl's if you use of \v and so that
                                ought to bring you closer to PCRE too unless the "PC" is now only
                                an historical leftover (I haven't looked at the specs in a long
                                time, but hey) The only thing I regularly miss in Vim regexes is
                                \Q...\E. \V...\v comes close, although you still have to escape
                                your backslashes under \V.

                                So I guess I should file a feature request for support of \Q,
                                although someone probably has already...

                                /bpj

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

                                ---
                                You received this message because you are subscribed to the Google Groups "vim_use" group.
                                To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                                For more options, visit https://groups.google.com/groups/opt_out.
                              • Nikolay Pavlov
                                ... To have this a way to embed variable is needed in first place. Otherwise you would need to escape E which can only be done with a more complex (compared
                                Message 15 of 23 , Jul 19 7:00 AM
                                • 0 Attachment


                                  On Jul 19, 2013 5:49 PM, "BPJ" <bpj@...> wrote:
                                  >
                                  > 2013-07-19 09:59, shawn wilson skrev:
                                  >
                                  >> On Jul 18, 2013 11:48 PM, "John Beckett" <johnb.beckett@...> wrote:
                                  >>>
                                  >>>
                                  >>> shawn wilson wrote:
                                  >>>>
                                  >>>> This is probably a feature request but I really do hate the
                                  >>>> regex engine and would love to swap it out. Is there / can
                                  >>>> there be a compile time option to use a different engine?
                                  >>>
                                  >>>
                                  >>> No (I assume you want different regex syntax, probably PCRE).
                                  >>>
                                  >>
                                  >> libpcre would be fine, yes. Or the library that Ruby uses - either way.
                                  >
                                  >
                                  >> Yeah, it looks like sed's syntax. If I'm used to writing things one way
                                  >> (say in code) and then hit '/' to do a similar thing inside my editor,
                                  >> switching mindset constantly makes me loose my thought (generally what
                                  >> happens) or make stupid errors like earlier in this thread.
                                  >
                                  >
                                  > I feel the same sometimes, as I code Perl in Vim on a daily
                                  > basis, but Vim's (old) regex engine/syntax actually allows useful
                                  > things which are impossible or hard inn Perl, not only the other
                                  > way around. And I can always filter through a perl oneliner if I
                                  > want to use perl's regex engine. Can't you do the same with Ruby?
                                  > Vim regexes come closer to Perl's if you use of \v and so that
                                  > ought to bring you closer to PCRE too unless the "PC" is now only
                                  > an historical leftover (I haven't looked at the specs in a long
                                  > time, but hey) The only thing I regularly miss in Vim regexes is
                                  > \Q...\E. \V...\v comes close, although you still have to escape
                                  > your backslashes under \V.
                                  >
                                  > So I guess I should file a feature request for support of \Q,
                                  > although someone probably has already...

                                  To have this a way to embed variable is needed in first place. Otherwise you would need to escape \E which can only be done with a more complex (compared to escape()) substitute() call or a new function. AFAIR embedding variables was indeed requested.

                                  The thing I constantly miss in vim RE engine is unicode and locales support.

                                  > /bpj
                                  >
                                  >
                                  > --
                                  > --
                                  > 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
                                  >
                                  > --- You received this message because you are subscribed to the Google Groups "vim_use" group.
                                  > To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                                  > For more options, visit https://groups.google.com/groups/opt_out.
                                  >
                                  >

                                  --
                                  --
                                  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
                                   
                                  ---
                                  You received this message because you are subscribed to the Google Groups "vim_use" group.
                                  To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                                  For more options, visit https://groups.google.com/groups/opt_out.
                                   
                                   
                                • Ben Fritz
                                  ... For searching it s not possible to use a different syntax, but you can easily do it for substitution via :perldo, :rubydo, :luado, etc. That is, if you
                                  Message 16 of 23 , Jul 19 7:02 AM
                                  • 0 Attachment
                                    On Friday, July 19, 2013 8:49:34 AM UTC-5, BPJ wrote:
                                    > 2013-07-19 09:59, shawn wilson skrev:
                                    >
                                    > > On Jul 18, 2013 11:48 PM, "John Beckett" <johnb.beckett@...> wrote:
                                    >
                                    > >>
                                    >
                                    > >> shawn wilson wrote:
                                    >
                                    > >>> This is probably a feature request but I really do hate the
                                    >
                                    > >>> regex engine and would love to swap it out. Is there / can
                                    >
                                    > >>> there be a compile time option to use a different engine?
                                    >
                                    >
                                    > I can always filter through a perl oneliner if I
                                    >
                                    > want to use perl's regex engine. Can't you do the same with Ruby?
                                    >

                                    For searching it's not possible to use a different syntax, but you can easily do it for substitution via :perldo, :rubydo, :luado, etc. That is, if you have your Vim compiled with support for your language of choice.

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

                                    ---
                                    You received this message because you are subscribed to the Google Groups "vim_use" group.
                                    To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                                    For more options, visit https://groups.google.com/groups/opt_out.
                                  • shawn wilson
                                    Just to be clear, I mentioned Ruby because don t like libpcre as much and haven t used ruby enough for Oniguruma (http://www.geocities.jp/kosako3/oniguruma/)
                                    Message 17 of 23 , Jul 19 7:25 AM
                                    • 0 Attachment
                                      Just to be clear, I mentioned Ruby because don't like libpcre as much
                                      and haven't used ruby enough for Oniguruma
                                      (http://www.geocities.jp/kosako3/oniguruma/) to piss me off and afaik,
                                      there would be no detatching perl's regex engine from perl. So it was
                                      more of a comment of "I know these exist, would it be a good thing to
                                      have and a decent feature request to have the ability to compile other
                                      regex eingines in".

                                      On Fri, Jul 19, 2013 at 10:02 AM, Ben Fritz <fritzophrenic@...> wrote:

                                      >
                                      > For searching it's not possible to use a different syntax, but you can easily do it for substitution via :perldo, :rubydo, :luado, etc. That is, if you have your Vim compiled with support for your language of choice.
                                      >

                                      That's awesome, no more dropping out of vim to do a perl -ne. Not what
                                      I'm looking for here, but awesome none-the-less.

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

                                      ---
                                      You received this message because you are subscribed to the Google Groups "vim_use" group.
                                      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                                      For more options, visit https://groups.google.com/groups/opt_out.
                                    • BPJ
                                      ... Perl s Q not only quotes interpolated variables, but also any metacharacters, so that Q[] E is equivalent to [ ], which is useful when searching for
                                      Message 18 of 23 , Jul 19 7:37 AM
                                      • 0 Attachment
                                        2013-07-19 16:00, Nikolay Pavlov skrev:
                                        > On Jul 19, 2013 5:49 PM, "BPJ" <bpj@...> wrote:
                                        >>
                                        >> 2013-07-19 09:59, shawn wilson skrev:
                                        >>
                                        >>> On Jul 18, 2013 11:48 PM, "John Beckett" <johnb.beckett@...> wrote:
                                        >>>>
                                        >>>>
                                        >>>> shawn wilson wrote:
                                        >>>>>
                                        >>>>> This is probably a feature request but I really do hate the
                                        >>>>> regex engine and would love to swap it out. Is there / can
                                        >>>>> there be a compile time option to use a different engine?
                                        >>>>
                                        >>>>
                                        >>>> No (I assume you want different regex syntax, probably PCRE).
                                        >>>>
                                        >>>
                                        >>> libpcre would be fine, yes. Or the library that Ruby uses - either way.
                                        >>
                                        >>
                                        >>> Yeah, it looks like sed's syntax. If I'm used to writing things one way
                                        >>> (say in code) and then hit '/' to do a similar thing inside my editor,
                                        >>> switching mindset constantly makes me loose my thought (generally what
                                        >>> happens) or make stupid errors like earlier in this thread.
                                        >>
                                        >>
                                        >> I feel the same sometimes, as I code Perl in Vim on a daily
                                        >> basis, but Vim's (old) regex engine/syntax actually allows useful
                                        >> things which are impossible or hard inn Perl, not only the other
                                        >> way around. And I can always filter through a perl oneliner if I
                                        >> want to use perl's regex engine. Can't you do the same with Ruby?
                                        >> Vim regexes come closer to Perl's if you use of \v and so that
                                        >> ought to bring you closer to PCRE too unless the "PC" is now only
                                        >> an historical leftover (I haven't looked at the specs in a long
                                        >> time, but hey) The only thing I regularly miss in Vim regexes is
                                        >> \Q...\E. \V...\v comes close, although you still have to escape
                                        >> your backslashes under \V.
                                        >>
                                        >> So I guess I should file a feature request for support of \Q,
                                        >> although someone probably has already...
                                        >
                                        > To have this a way to embed variable is needed in first place. Otherwise
                                        > you would need to escape \E which can only be done with a more complex

                                        Perl's \Q not only quotes interpolated variables,
                                        but also any metacharacters, so that \Q[]\E is equivalent to \[\],
                                        which is useful when searching for perl variables...

                                        The way Perl's \Q does (not) interact with \\E is indeed annoying

                                        > (compared to escape()) substitute() call or a new function. AFAIR embedding
                                        > variables was indeed requested.

                                        Some syntax for that, like \%{varname} could be added to Vim.

                                        >
                                        > The thing I constantly miss in vim RE engine is unicode and locales support.

                                        Yeah, but I've kind of resigned to the lack of it, but it would be
                                        nice to get rid of the shenanigans I use to make up, for sure!

                                        BTW I'm on a UTF-8 locale, so I seldom need (other) locales.

                                        >
                                        >> /bpj
                                        >>
                                        >>
                                        >> --
                                        >> --
                                        >> 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
                                        >>
                                        >> --- You received this message because you are subscribed to the Google
                                        > Groups "vim_use" group.
                                        >> To unsubscribe from this group and stop receiving emails from it, send an
                                        > email to vim_use+unsubscribe@....
                                        >> For more options, visit https://groups.google.com/groups/opt_out.
                                        >>
                                        >>
                                        >

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

                                        ---
                                        You received this message because you are subscribed to the Google Groups "vim_use" group.
                                        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                                        For more options, visit https://groups.google.com/groups/opt_out.
                                      • BPJ
                                        ... I actually prefer :!perl ... since that way I can use a current version of perl without building vim myself. /bpj -- -- You received this message from the
                                        Message 19 of 23 , Jul 19 7:37 AM
                                        • 0 Attachment
                                          2013-07-19 16:02, Ben Fritz skrev:
                                          > For searching it's not possible to use a different syntax, but you can easily do it for substitution via :perldo, :rubydo, :luado, etc. That is, if you have your Vim compiled with support for your language of choice.

                                          I actually prefer :!perl ... since that way I can use a current
                                          version of perl without building vim myself.

                                          /bpj

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

                                          ---
                                          You received this message because you are subscribed to the Google Groups "vim_use" group.
                                          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                                          For more options, visit https://groups.google.com/groups/opt_out.
                                        • Nikolay Pavlov
                                          ... is useful when searching for perl variables... ... embedding ... support. ... to get rid of the shenanigans I use to make up, for sure! ... You missed the
                                          Message 20 of 23 , Jul 19 8:40 AM
                                          • 0 Attachment


                                            On Jul 19, 2013 6:37 PM, "BPJ" <bpj@...> wrote:
                                            >
                                            > 2013-07-19 16:00, Nikolay Pavlov skrev:
                                            >
                                            >> On Jul 19, 2013 5:49 PM, "BPJ" <bpj@...> wrote:
                                            >>>
                                            >>>
                                            >>> 2013-07-19 09:59, shawn wilson skrev:
                                            >>>
                                            >>>> On Jul 18, 2013 11:48 PM, "John Beckett" <johnb.beckett@...> wrote:
                                            >>>>>
                                            >>>>>
                                            >>>>>
                                            >>>>> shawn wilson wrote:
                                            >>>>>>
                                            >>>>>>
                                            >>>>>> This is probably a feature request but I really do hate the
                                            >>>>>> regex engine and would love to swap it out. Is there / can
                                            >>>>>> there be a compile time option to use a different engine?
                                            >>>>>
                                            >>>>>
                                            >>>>>
                                            >>>>> No (I assume you want different regex syntax, probably PCRE).
                                            >>>>>
                                            >>>>
                                            >>>> libpcre would be fine, yes. Or the library that Ruby uses - either way.
                                            >>>
                                            >>>
                                            >>>
                                            >>>> Yeah, it looks like sed's syntax. If I'm used to writing things one way
                                            >>>> (say in code) and then hit '/' to do a similar thing inside my editor,
                                            >>>> switching mindset constantly makes me loose my thought (generally what
                                            >>>> happens) or make stupid errors like earlier in this thread.
                                            >>>
                                            >>>
                                            >>>
                                            >>> I feel the same sometimes, as I code Perl in Vim on a daily
                                            >>> basis, but Vim's (old) regex engine/syntax actually allows useful
                                            >>> things which are impossible or hard inn Perl, not only the other
                                            >>> way around. And I can always filter through a perl oneliner if I
                                            >>> want to use perl's regex engine. Can't you do the same with Ruby?
                                            >>> Vim regexes come closer to Perl's if you use of \v and so that
                                            >>> ought to bring you closer to PCRE too unless the "PC" is now only
                                            >>> an historical leftover (I haven't looked at the specs in a long
                                            >>> time, but hey) The only thing I regularly miss in Vim regexes is
                                            >>> \Q...\E. \V...\v comes close, although you still have to escape
                                            >>> your backslashes under \V.
                                            >>>
                                            >>> So I guess I should file a feature request for support of \Q,
                                            >>> although someone probably has already...
                                            >>
                                            >>
                                            >> To have this a way to embed variable is needed in first place. Otherwise
                                            >> you would need to escape \E which can only be done with a more complex
                                            >
                                            >
                                            > Perl's \Q not only quotes interpolated variables,
                                            > but also any metacharacters, so that \Q[]\E is equivalent to \[\], which is useful when searching for perl variables...
                                            >
                                            > The way Perl's \Q does (not) interact with \\E is indeed annoying
                                            >
                                            >
                                            >> (compared to escape()) substitute() call or a new function. AFAIR embedding
                                            >> variables was indeed requested.
                                            >
                                            >
                                            > Some syntax for that, like \%{varname} could be added to Vim.
                                            >
                                            >
                                            >>
                                            >> The thing I constantly miss in vim RE engine is unicode and locales support.
                                            >
                                            >
                                            > Yeah, but I've kind of resigned to the lack of it, but it would be nice to get rid of the shenanigans I use to make up, for sure!
                                            >
                                            > BTW I'm on a UTF-8 locale, so I seldom need (other) locales.

                                            You missed the point of locales. It is not about encoding, it is about language and affects ranges (what characters match a-z range depends on language you set in your locale) and a big bunch of other things I do not care about. Ranges matter for me only because ё (CYRILLIC ... LETTER IO) is not in range а-я (CYRILLIC ... LETTER A-YA), while it must be there if you are talking about Russian alphabet. For locales not to break scripts and degrade performance new regex flag have to be introduced. Python has this support, and it has it with additional flag. Do not remember about perl.

                                            Also note that range а-я is utterly broken with &enc set to KOI8-R.

                                            >
                                            >>
                                            >>> /bpj
                                            >>>
                                            >>>
                                            >>> --
                                            >>> --
                                            >>> 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
                                            >>>
                                            >>> --- You received this message because you are subscribed to the Google
                                            >>
                                            >> Groups "vim_use" group.
                                            >>>
                                            >>> To unsubscribe from this group and stop receiving emails from it, send an
                                            >>
                                            >> email to vim_use+unsubscribe@....
                                            >>>
                                            >>> For more options, visit https://groups.google.com/groups/opt_out.
                                            >>>
                                            >>>
                                            >>
                                            >
                                            > --
                                            > --
                                            > 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
                                            >
                                            > --- You received this message because you are subscribed to the Google Groups "vim_use" group.
                                            > To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                                            > For more options, visit https://groups.google.com/groups/opt_out.
                                            >
                                            >

                                            --
                                            --
                                            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
                                             
                                            ---
                                            You received this message because you are subscribed to the Google Groups "vim_use" group.
                                            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                                            For more options, visit https://groups.google.com/groups/opt_out.
                                             
                                             
                                          • BPJ
                                            ... I know, but I usually deal with languages that are so exotic or so extinct that there are no locales for them, or with such philologists tics like
                                            Message 21 of 23 , Jul 19 11:46 AM
                                            • 0 Attachment
                                              2013-07-19 17:40, Nikolay Pavlov skrev:
                                              > You missed the point of locales. It is not about encoding, it is about
                                              > language and affects ranges (what characters match a-z range depends on
                                              > language you set in your locale) and a big bunch of other things I do not
                                              > care about.

                                              I know, but I usually deal with languages that are so exotic or so
                                              extinct that there are no locales for them, or with such
                                              philologists' tics like typesetting a language in romanization,
                                              yet sort it as if it were in the native script. There ain't no
                                              locales for that either. I'm just happy that I can get UTF-8
                                              I/O out of the box and that there are tools to do such sorting,
                                              but for the most part I've had to write my own tools. Luckily
                                              user-defined character properties can make up for missing ranges
                                              to a degree.
                                              (<https://metacpan.org/module/perlunicode#User-Defined-Character-Properties>),
                                              and ack as grepprg goes a long
                                              way towards having unicode-aware searching in vim.

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

                                              ---
                                              You received this message because you are subscribed to the Google Groups "vim_use" group.
                                              To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                                              For more options, visit https://groups.google.com/groups/opt_out.
                                            Your message has been successfully submitted and would be delivered to recipients shortly.