Jump to content

How to clear a pattern match in vim?


Recommended Posts

I think this is programming related, anyway...

 

I was using vim last night to edit some programs and accidently typed in '/y'. Now the program is highlighting every y on the page. And to make things worse, this pattern matching persists beyond closing the program.

 

I am a vim newbie, how do I turn this off?

Link to comment
Share on other sites

Yep, I can pattern match anything and the annoying highlights just shift to the new pattern. And yea, it persists.

 

Very annoying. I will check out the link above for the answer.

 

 

No vim gurus out there?!?

Link to comment
Share on other sites

I think this is programming related, anyway...

 

I was using vim last night to edit some programs and accidently typed in '/y'. Now the program is highlighting every y on the page. And to make things worse, this pattern matching persists beyond closing the program.

 

I am a vim newbie, how do I turn this off?

 

Within the session, after a search you can remove the highlight by typing in command mode ":noh" , or faster, enter a new search which doesn't exist (ie: /adfasdfasd)

 

If you dislike the search highlighting and you want to remove that feature, then edit your ~/.vimrc file and append this: "set nohlsearch"

Link to comment
Share on other sites

  • 7 years later...
Guest lahtris

put this in your .vimrc

 

nmap <SPACE> <SPACE>:noh<CR>

 

after you perform a search, pressing space in normal mode will still do what space did (usually advance one character), but also clear the highlighting. This way, you can leave the highlighting on if you want (by not hitting space).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...