Highlight only a portion of a search term in Vim
I'm looking for a way to have vim's search highlighting work on only a part of my search term.
I'm viewing a huge log file of data dumps. It looks something like this: field1: 12345 field2: 12345 field3: 12345 field4: 12345 field5: 12345 ... field1: 11111 field2: 22222 field3: 33333 ... and so on.
I'd like to be able to have all of the fieldX values highlighted for a moment, then quickly switch to highlighting 开发者_JAVA百科the values for fieldY. Is it possible to search for something like 'field3: \d\d\d\d\d' and have only the number part highlighted?
So in searching for 'my highlight search term' I'd like only 'highlight' to get highlighted.
Thanks,
Andrew
If I am understanding your question correctly, you can try searching like this:
/field3: \zs\d\d\d\d\d
That will highlight any numbers (and only the numbers) that come after field3:
For quick switching, you could try: /
, up-arrow
, change field3
to field2
.
Is that what you were looking for?
well highlight fieldY i'm not sure (a lil bit of a vim noob) but you should be able to just goto the next work by typing w
to get to the next fieldX, type n
this won't highlight fieldy but it will put your cursor at the beginning of that number
Not exactly what you're searching, but running:
:%!column -t
will make your columns more visible
精彩评论