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

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

Expand Messages
  • Ben Fritz
    Dec 13, 2012
      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
    • Show all 5 messages in this topic