I would like to use a slash (
/) for a search during a vimscript, but I don't want to overwrite the"/register. How do I do this?
In my particular example, I am working on a custom vim text object for LaTeX, a$, to specify the region between and including the previous and next dollar signs ($ characters, which delimit math mode in LaTeX). I'm following a guide found here which suggests using a vnoremap and an omap command, which is a simple enough approach. What I would like to write is:
vnoremap a$ :<C-U> execute "normal! ?\\$\rvN"<CR>
omap a$ :normal va$<CR>
However, this implementation has a fatal flaw: the "/ register becomes overwritten with the search for the dollar sign character, clearing any previous search and causing confusion and inefficiencies when trying to use n or N next.