3

I have a file with two columns, separated by a tab, and would like to match any part of the second column that begins with an asterisk. For example:

  RAFP         rasp
  ET           *ratchet

then *ratchet should be highlighted. (There are two spaces before the first column, and there are supposed to be – in some other rows, there are symbols placed in that space.)

Therefore, I wrote the following match line:

syntax match Keyword "\t\*.*"

It does not highlight anything. I have tried removing and adding escape characters, putting elements in square brackets, playing with the magic option (though I see in the help that syntax matches are always in magic mode no matter what) and just about everything else possible. If I take out the \t, then it works as expected, but this has the potential for false positives, so it's important that the pattern start with the tab.

Most baffling, if I do a simple search for \t\*.* with hlsearch on, it highlights exactly like it's supposed to. What is different about the pattern matching in a syntax highlight command from the normal search matching system?

I'm using Vim 7.4 (I can give more version output if it's relevant).

closed as off-topic by Martin Tournoij Mar 2 '16 at 12:58

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers." – Martin Tournoij
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    Did you try inserting a literal tab character in the regexp? With <C-v><Tab>? – Martin Tournoij Jul 30 '15 at 22:27
  • Your syntax command line works for me, highlighting everything from the tab to the end of the line. I'm on Vim 7.4 too. – Peter Lewerin Jul 31 '15 at 9:29
  • That's interesting... I did try <C-v><Tab>, yes, sorry for missing that. It inserts a ^I character, and it doesn't work either. – Soren Bjornstad Jul 31 '15 at 15:38
  • You example syntax command seems to work, as it is in the answer. The word *ratchet gets highlighted as a keyword (brown-isn in my case), and the tab just before it is also highlighted (which is only visible when you move the cursor over it). How did you try to apply the :syntax rule? – Martin Tournoij Aug 7 '15 at 13:13