Tuesday, January 17, 2017

RE: How to prevent asterisk key from advancing to next match when pressed

Look at the SearchAlternatives plugin. When you add an item to the search list, it does not advance to the next match.


-----Original Message-----
From: vim_use@googlegroups.com [mailto:vim_use@googlegroups.com] On Behalf Of Slartibartfast
Sent: Wednesday, December 14, 2016 1:03 AM
To: vim_use
Subject: How to prevent asterisk key from advancing to next match when pressed

I frequently use the asterisk key (*) in conjunction with 'hlsearch' to highlight all occurrences of a word in a file. Normally when I do this I don't actually want to advance to the next match so I use 'nnoremap' to automatically wind back to the occurrence I was on when I pressed the key, as in:
:set nnoremap * *N

For the most part this works fine, however if the next occurrence of a match is off the screen the 'N' command does indeed bring you back to the correct place but that line is then placed at the top of the screen. One can of course remap to "*Nzz" to then bring that line to the center of the screen but that's a bit of a kludge as well.

Anyone know a way to achieve setting the search word like this without causing the screen to be scrolled? I'm sure it must be possible but I'm having trouble working it out myself.

Thanks.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: