Note that there are some explanatory texts on larger screens.

plurals
  1. POvim: visual star search not working as expected
    primarykey
    data
    text
    <p>I copied this function to visually search with <code>*</code> and <code>#</code>:</p> <pre><code>function! s:VSetSearch(cmdtype) let temp = @s norm! gv"sy let @/ = '\V' . substitute(escape(@s, a:cmdtype.'\'), '\n', '\\n', 'g') let @s = temp endfunction xnoremap * :&lt;C-u&gt;call &lt;SID&gt;VSetSearch('/')&lt;CR&gt;/&lt;C-R&gt;=@/&lt;CR&gt;&lt;CR&gt; xnoremap # :&lt;C-u&gt;call &lt;SID&gt;VSetSearch('?')&lt;CR&gt;?&lt;C-R&gt;=@/&lt;CR&gt;&lt;CR&gt; </code></pre> <p>The <code>#</code> mapping works fine but the <code>*</code> mapping doesn't exit visual selection (it extends the range of the visual selection until the next searched word). I don't understand why this is happening. Is there a solution? </p> <p><strong>EDIT:</strong> To reproduce the problem save the code snippet, download the <a href="ftp://ftp.vim.org/pub/vim/pc/gvim74.exe" rel="nofollow">MS Installer</a>, open <code>cmd.exe</code> and start vim <code>vim -u NONE</code>, then do <code>:set nocp</code> and finally source the saved code. In fact, the following simple mapping doesn't work either:</p> <pre><code>nnoremap * *&lt;C-o&gt; </code></pre> <p><strong>EDIT 2:</strong> Can someone else reproduce this issue? Should it be reported?</p> <p><strong>EDIT 3:</strong> I believe that the problem (bug?) is that the <code>*</code> (star) key cannot be remapped: if I start vim with <code>vim -N -u NONE</code> (Vim 7.4 with patches 1-274) and run the command <code>:noremap * :echo "star"&lt;CR&gt;</code> and press <code>*</code>, vim tries to perform a search. I also reported <a href="https://groups.google.com/forum/#!topic/vim_dev/nkcV51bsQuc" rel="nofollow">this</a> to the vim dev group.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload