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

1

6

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.

Pathe answered 25/10, 2018 at 14:24 Comment(0)
M
9

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).

Meander answered 25/10, 2018 at 19:31 Comment(2)
This doesn't really explain why VSVim randomly overrides Ctrl-C/V etc...Darkling
@JoshMathews If this happens randomly despite following the the wiki the bug tracker of VsVim is the right place - not SO.Meander

© 2022 - 2024 — McMap. All rights reserved.