title: Searching backward for visual mode selection
body: <p>I am looking to remap my <code>#</code> and <code>*</code> keys in visual mode in Vim so that I am able to highlight a portion of text and search for it backwards and forwards, respectively. With the help of <a href="https://stackoverflow.com/a/9261629/866235">a previous answer</a> I have managed to get forward searches working. I am having difficulty getting backward searching to work however. Below are the relevant parts of my <code>.vimrc</code>. </p>
  
  <pre><code>function! GetVisualSelection() abort
    try
      let a_save = @a
      silent! normal! gv"ay
      return @a
    finally
      let @a = a_save
    endtry
  endfunction
  
  " Map # and * to search for the highlighted text in visual mode
  vnoremap &lt;silent&gt; * &lt;c-\&gt;&lt;c-n&gt;:let @/ = escape(GetVisualSelection(), '/\^$*.[~')&lt;CR&gt;n
  vnoremap &lt;silent&gt; # &lt;c-\&gt;&lt;c-n&gt;:let @/ = escape(GetVisualSelection(), '/\^$*.[~')&lt;CR&gt;N
  </code></pre>
  
  <p>The initial highlight and search backwards works well, but then once I press <code>n</code> to search for the next occurrence backwards, instead Vim resumes searching forward. I suspect this is because backward searches use the <code>?</code> operator instead of <code>/</code>, which would mean I would have to press <code>N</code> instead of <code>n</code>. However this is counter-intuitive to the normal mode operation of <code>#</code>, so I attempted to assign the selection to the <code>?</code> register, only to find that there is no register named <code>?</code>. How would I solve this issue? Ideally I would prefer to do this without installing a plugin.</p>