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

Re: Syntax highlighting: "operator keywords"

Expand Messages
  • A.Politz
    ... You can make your own with the @
    Message 1 of 2 , Jan 30, 2008
    • 0 Attachment
      Szabolcs wrote:

      >With syntax highlighting, \< and \> are very useful for isolating
      >keywords. What a simple way of doing the same thing for operators
      >that are made up of a certain set of characters?
      >For example, suppose that operators can be made up of these three
      >chars: ./+
      >I would like to highlight all of the following: . + / ++ /. .. ...
      >But none of the following (or other combinations): .+ +++ ./ +/ ./+
      >What is the simplest solution for this?
      >To complicate matters further: an operator can be surrounded by non-
      >operator chars such as whitespace, digits, letters, (, ), etc.
      >However, when a dot (.) is next to a number, it should always be
      >grouped with that number as a decimal point: e.g. /.2 is grouped as /
      >(.2) and not (/.)2
      >Similarly 2..a is (2.)(.)(a) and not (2)(..)(a)
      >Any suggestions for solving these problems would be most welcome!
      You can make your own '\<,\>' with the @<= ,@<! and @= operators.
      Here are some hints, you can read more at ':h pattern'. '\v' stands
      for verymagic, which spares a lot of backslashes. Most parens are
      just for clarity.

      Match a 'b', but not after/before an 'a'.

      The same using '@<='.

      The same using '@<=' and '&'.

      Match 1-3 adjacent 'b's.

      Match 1-3 adjacent 'b's, not after/before a digit.

      > Similarly 2..a is (2.)(.)(a) and not (2)(..)(a)


      This matches 1-3 dots after start of line, a digit and a dot or
      something that is neither a dot nor a digit, and is followed by
      the end of line, a dot and a digit or neither one of them.


      Ich hab geträumt, der Krieg wär vorbei.

      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
    Your message has been successfully submitted and would be delivered to recipients shortly.