Search code examples
vimsyntaxsyntax-highlightingvim-syntax-highlighting

What is the syntax called that's used for syntax highlighting?


My apologies if this is such a trivial question for most, but it is not readily obvious to me and I can't find an answer. I am trying to understand how to code syntax highlighting for vi, but the syntax used [for the syntax highlighting] eludes me. For example, I know that

syn match myNumber '\d\+'
hi myNumber ctermfg=blue

will highlight positive integers blue. What confuses me is the '\d\+' part. Playing around it seems that \d means digit and \+ means several? But I have no idea what this syntax is called and thus can't find any documentation that could help me. I have only found links of people using it without explanation. I can probably decipher how

'[-+]\=\d[[:digit:]]*\.\d*[eE][\-+]\=\d\+'

means 'positive and negative numbers with decimals and exponents', but if I am to make more complex highlighting I don't know where to begin. Does anybody know of any documentation that I could use to learn this?


Solution

  • That's called a "regular expression" or regex (or regexp) for short. See :help pattern and :help usr_27.txt. Also see vimregex.com.