vimvisual-studio-2017vsvim

Can't configure VsVim to let Visual Studio handle ctrl+c, ctrl+v and ctrl+x


I've been using VsVim for about a year now. I was always able to to copy/paste text using default ctrl+c and ctrl+v shortcuts. It stopped working for me a few days ago. I figured VsVim Keyboard setting must've changed somehow, to handle those keys instead letting Visual Studio do it. Currently pressing Ctrl+v toggles Visual Mode. The problem is there are no ctrl+v or ctrl+c entries in the vsvim settings. Any workarounds for this? I hate having to right-click my mouse to get to the copy/paste menu, and the clipboard buffer is even more of a pain.


Solution

  • The VsVim Wiki talks about this particular problem.

    As stated there

    If you choose to have VsVim handle Ctrl-X/C/V, you can add the following to the _vsvimrc file in order to arrive at a standard Windows behavior:

    This means:

    1.) If it doesn't exist, create a file _vsvimrc in your %userprofile% (most likely something like C:\Users\YOURUSERNAME\).

    2.) Add the following code to this file:

    " CTRL-X and SHIFT-Del are Cut
    vnoremap <C-X> "+x
    vnoremap <S-Del> "+x
    
    " CTRL-C and CTRL-Insert are Copy
    vnoremap <C-C> "+y
    vnoremap <C-Insert> "+y
    
    " CTRL-V and SHIFT-Insert are Paste
    map <C-V>       "+gP
    map <S-Insert>      "+gP
    imap <C-V>      <Esc>"+gpa
    
    cmap <C-V>      <C-R>+
    cmap <S-Insert>     <C-R>+
    
    
    imap <S-Insert>     <C-V>
    vmap <S-Insert>     <C-V>
    
    " Use CTRL-Q to do what CTRL-V used to do
    noremap <C-Q>       <C-V>
    

    You can adjust these settings to fit your needs.

    _vsvimrc will be loaded last and therefore override options that have been set before from what ever configuration.

    The above VsVim Wiki link has more useful keybindings to get Windows-like behaviour (e.g. CTRL-Z to undo with noremap <C-Z> u).