I am currently working on a custom syntax highlighting for vim. I want to highlight lines starting with a space, but only if they contain any letters or numbers.I could achieve this result with the syn match '^ .*.[a-zA-Z].*', but I want the highlight to be working only if the previous line does not end with a =.Is this possible?Thanks!
Syntax highlighting for not empty line starting with a space, but only if the previous line did not end with =
syntax highlighting
Here is a sample text to test the regex you want to build :this line doesn't begin with a space this line begins with a space and the previous line doesn't end with = this line begins with a space and the previous line ends with =The set of characters [a-zA-Z] can be expressed with the atom \a.So your regex can be rewritten like this :^ .*.\a.*Now your regex uses the ^ character, which stands for a beginning of a line. The problem is it can only be used at the beginning of the regex. To describe a beginning of line anywhere inside the regex, you have to use \_^.Finally, you don't want the previous line to begin with the character =.This can be expressed with the following regex (in very magic mode) :(\=\n)@<!The end result is :(\=\n)@<!\_^ .*.\a.*Or if you want to be sure the very magic mode is enabled :\v(\=\n)@<!\_^ .*.\a.*