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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...