3

While in INSERT mode, I'd like to make <c-r>* behave as <c-r>+. Is that possible?

I tried both of the following, but no luck:

inoremap <c-r>* <c-r>+
onoremap * +

Is it possible to do it?

EDIT, Dec 11th: The solution I tried (inoremap <c-r>* <c-r>+) is the answer, but sometimes that doesn't always work, and I'm not entirely sure why (it might have to do with timeouts as mentioned in the comments, and sometimes the timeout behavior changes on me at some random point into my NeoVim session).

EDIT, Dec 12th: This is what I'm trying to achieve, as per a comment I wrote in my vimrc:

    " COPY/PASTE
        " Make "* behave the same on all OSes. In linux, "* uses the
        " SECONDARY register for pasting with a mouse middle click, but I
        " never use that. In OS X, "* uses the same register as "+, which
        " is the behavior I like.
            noremap "* "+
            inoremap <c-r>* <c-r>+
  • 1
    Operator-pending mode has nothing to do with <C-r>, it is for normal-mode commands like d. First variant does work for me, if it does not for you check :h timeoutlen and :h timeout. – ZyX Dec 12 '15 at 4:39
  • It is also possible that first mapping does not work as you are in compatible mode. Specifically &cpoptions setting must not contain <. Fixed either by adding set nocompatible explicitly at the start of the vimrc (and verifying that no command adds < to &cpoptions later), or by using inoremap <special> <C-r>* <C-r>+. This variant is rather unlikely because Vim starts in nocompatible mode when it finds ~/.vimrc file (except for the case when you used -u ~/.vimrc). – ZyX Dec 12 '15 at 4:45
  • The first mapping works fine for me. Another reason why it might not work for you would be if you have set notimeout, or you have set timeoutlen or ttimeoutlen too low. :verb set timeout? timeoutlen? ttimeoutlen? to check. – joeytwiddle Dec 12 '15 at 4:49
  • Thanks for the input guys. Here's my timeout config: trusktr.io:7777/xepuhoduki. – trusktr Dec 12 '15 at 7:22
  • 1
    Alright, so it seems to be working for me now. I disabled set notimeout, but then I re-enabled it, and now it keeps working. It's strange to me. Maybe there's a subtle bug in Neovim, as I've had the timeout behavior randomly change after a while too... – trusktr Dec 12 '15 at 7:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.