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?