0
Is it possible to save/restore Vim search terms in a map
?
For instance, I have the following in my .vimrc
:
map ,/ :s/^/\/\//<CR>
If I have turned on highlighting (:set hls
) previously in the session, then when I invoke the above mapping the first column of every line will be highlighted.
Would it be possible to instead save the current search term (if any), then perform the search/replace, then restore the last search term (if any) instead?
I had to remove the
<CR>
from the function to fix an error about trailing characters, but other than that this is perfect. – wes – 2014-09-25T21:55:43.410Opps, I'll update my answer. – Brett Y – 2014-09-25T22:13:32.993