Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highlight only first match

Tags:

vim

With Vim, I want to highlight only the first match of an expression.

For instance, in the following text I want to highlight only the first a :

bdjh abc olkd abc abc

How can I realize this ?

like image 726
Ekans Avatar asked May 19 '14 09:05

Ekans


People also ask

How do you highlight a cell if it doesn't match another cell?

Highlight When Cells Do Not Equal Select the range you want to apply formatting to. In the Ribbon, select Home > Conditional Formatting > New Rule.


1 Answers

You can make it explicit

/^.\{-}\zsa

This does:

  • ^ (match start of line)
  • .\{-} (match as few characters as possible)
  • \zs (start of match)
  • a (your pattern)

enter image description here

like image 56
sehe Avatar answered Oct 03 '22 13:10

sehe