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

Re: Feature request: Regex "not identifier" character class.

Expand Messages
  • Nate Soares
    +1 to [:identifier:] and [:keyword:]. Unfortunately, outside of i and k convention is that uppercase means negation ( s and S, w and W, etc.). We can t
    Message 1 of 5 , Dec 13, 2012
    • 0 Attachment
      +1 to [:identifier:] and [:keyword:].

      Unfortunately, outside of \i and \k convention is that uppercase means negation (\s and \S, \w and \W, etc.). We can't use that because \I and \K already exist (and \I\i* is a fairly useful pattern).

      I'm +0 on \- meaning negation. You'd then have overlap between \S and \-s but I do think it's nice to have a way to match [^[:identifier:]] without resorting to the square bracket negation.


      On Thu, Dec 13, 2012 at 1:44 PM, Ben Fritz <fritzophrenic@...> wrote:
      On Thursday, December 13, 2012 3:28:26 PM UTC-6, Bram Moolenaar wrote:
      > So8res wrote:
      >
      >
      >
      > > The \i and \k regex character classes are very useful, matching
      >
      > > identifier and keyword characters respectively. You might think that
      >
      > > \I and \K match non-(identifier,keyword) characters, but that is not
      >
      > > what they do.
      >
      > >
      >
      > > As far as I can tell, there's no (easy) way in a regex to match
      >
      > > non-identifier/non-keyword characters.
      >
      > >
      >
      > > I propose adding such character classes, potentially under the names
      >
      > > \_i and \_k. I'm not entirely satisfied with those. Any other
      >
      > > suggestions for names?
      >
      > >
      >
      > > (Alternatively, is there a way to do this that I couldn't find in the help?)
      >
      >
      >
      > Right, it's not easy to match the opposite of \i and \k.
      >
      >
      >
      > \_ is reserved for items including a line break.
      >
      >
      >
      > Perhaps we can make a generic solution with \- meaning "the opposite
      >
      > of".  At least instead of finding the few characters that don't have a
      >
      > meaning yet.
      >

      What about instead of trying to find characters to pair with a \, we just define new classes similar to [[:alnum:]] like [[:identifier:]] and [[:keyword:]] and maybe [[:fname:]]. Then non-matches would just use negation with [^...] just like other character classes.

      --
      You received this message from the "vim_dev" 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.