Vsvim: Unable to override Ctrl+K

Created on 17 Apr 2013  路  18Comments  路  Source: VsVim/VsVim

When using VsVim in Visual Studio 2012 it does not appear to be possible to let VsVim control the behaviour of Ctrl+K.

Even after manually removing/rebinding all Visual Studio shortcuts that start with Ctrl+K, my vim binding is still being ignored.

bug keyboard conflict

Most helpful comment

I experienced the same problem today when I installed VsVim (v 2.1.1.0) in VS 2015 for the first time. My .vimrc uses Ctrl+K and Ctrl+J to scroll up and down:

nnoremap <C-k> 2<C-y>
nnoremap <C-j> 2<C-e>

Ctrl+J worked after setting VsVim to handle all its shortcuts. Ctrl+K didn't work despite telling VsVim to handle it.

I tried removing all the Ctrl+K shortcuts like @jazzdelightsme suggested, but that didn't resolve the problem for me. Visual Studio continued to prompt for a second chord when using Ctrl+K.

What finally resolved the problem for me was assigning Ctrl+K to another command, then removing it again. I'm not sure what that did in the background, but Visual Studio now follows my .vimrc instead of prompting for a second chord.

In case it helps anyone, here are the full steps I used.

First, remove all shortcuts that contain Ctrl+K:

  1. From the Tools menu, click Options.
  2. From the left-hand menu, click Keyboard.
  3. From the Commands list, click any command with no shortcuts assigned.
  4. In the Press Shortcut Keys box, enter Ctrl+K, but do not click Assign. The Shortcut Currently Used By dropdown will show a list of all commands containing Ctrl+K. Make a note of these commands for reference in Step 5.
  5. For each of the commands:

    1. In the Show Commands Containing box, type the command's name.

    2. From the Commands list, click the command.

    3. From the Shortcuts For Selected Command dropdown, click each shortcut that contains Ctrl+K and then click Remove to remove it.

  6. Click OK to save the changes.

Next, assign Ctrl+K to a command and then remove it again:

  1. From the Tools menu, click Options.
  2. From the left-hand menu, click Keyboard.
  3. From the Commands list, click any command with no shortcuts assigned.
  4. In the Press Shortcut Keys box, enter Ctrl+K, and then click Assign.
  5. From the Shortcuts For Selected Command dropdown, click the Ctrl+K shortcut and then click Remove.
  6. Click OK to save the changes.

Now try using Ctrl+K. It should behave according to your .vimrc.

All 18 comments

Thanks for reporting the issue!

I'm looking into this.

I also ran into this problem--I couldn't get configure VsVim to capture Ctrl+K. However, I was able to work around the problem by removing all Visual Studio keybindings that use Ctrl+K. I'm on Visual Studio 2013, VsVim 1.4.20.

I'm seeing this with VS 2013 and VsVim version 1.7.1.1, and I've been unable to get it to work. I removed all of the key bindings for ctrl-k when VsVim was listed as the handler for ctrl-k, and that didn't work. So, I set visual studio as the handler and then removed all of the key bindings for ctrl-k and then set VsVim as the handler again, and that still wasn't enough. So, I don't know what the deal is, especially if jazzdelightsme was able to get it working with VS 2013. But there are a _lot_ of bindings that use ctrl-k, so maybe that has something to do with it somehow. My problem might be exacerbated by the fact that I'm trying to remap it to ctrl-v (since I'm using dvorak, and its k is where qwerty's v is), but trying other ctrl bindings instead of ctrl-v didn't seem to work either.

But even so, VsVim does _way_ better than similar solutions that I've seen in other IDEs in the past (e.g. eclipse), I'm very glad to have it. Thanks for your work on this.

I have no need to bind Ctrl+K but for comparison, for me with Visual Studio 2013:

  • it is not listed in the VsVim keybindings list
  • It is bound as a global prefix to a couple of dozen Visual Studio commands
  • it has this dead giveaway that Visual Studio is the one processing it:

image

@ricksladkey @jmdavis yep. I recently learned of a class of key bindings than VsVim is having trouble removing. It is apparently possible for packages to define commands which have no name but do have key bindings associated with them. Such commands cannot have their key bindings removed by normal means. VsVim has to do some nasty tricks to get rid of them.

It sounds like this is what is happening here. The next version of VsVim has a big hammer feature for removing such bindings that should take care of this.

Issue #858 captures all the details of this problem.

@jaredpar How fun! :|

@ricksladkey I suspect that ctrl-k is only in my vsvim list because of my vimrc and that you don't see it there, because you haven't created a conflicting binding with it in your vimrc. And I do see what you're showing there where VS is complaining about chords. The bizarre thing is that I've removed all of the bindings involving ctrl-k in the VS keybinding settings, and it's still not enough, but if the bindings don't have names, I don't know how they could show up in the VS keybindings list, since all of that is by name. Hopefully, the "hammer" in the next version will do the trick. Overall though, I'm very pleasantly surprised at how will vsvim is working and how well it's able to remap keys. Having my normal vimrc almost "just work" is pretty fantastic.

I'm using VS 2013 and still having this same problem yet. Has anybody found a fix yet?

@DJMcMayhem have you tried to remove it with the latest version of VsVim (2.0 branch)?

@jaredpar Ah, well there's my problem. I was on 1.8. Installing 2.0.1.0 fixed it for me. Thankyou!

This problem has resurfaced. I had to reinstall VS 2013, and vsvim 2.0.1.0, and I am still having difficulties getting vsvim to see my ctrl-k press. I'm seeing the same thing as Ricksladkey, even though I have removed every visual studio ctrl-k binding. Considering I'm using the exact same version of VS and the same version of vsvim, I think this qualifies as a Heisenbug. =( Any clue what could be causing this? I might do some digging to see if I can figure anything out,

I'm having the same problem as @DJMcMayhem as well. Even with control switched over to VsVim in the options dialog, the blue "(Ctrl-K) was pressed. Waiting for second key of chord..." bar appears.

Same here with VS 2010 and VS 2015 with VsVim 2.0.1.0.
Any news on this issue?

I experienced the same problem today when I installed VsVim (v 2.1.1.0) in VS 2015 for the first time. My .vimrc uses Ctrl+K and Ctrl+J to scroll up and down:

nnoremap <C-k> 2<C-y>
nnoremap <C-j> 2<C-e>

Ctrl+J worked after setting VsVim to handle all its shortcuts. Ctrl+K didn't work despite telling VsVim to handle it.

I tried removing all the Ctrl+K shortcuts like @jazzdelightsme suggested, but that didn't resolve the problem for me. Visual Studio continued to prompt for a second chord when using Ctrl+K.

What finally resolved the problem for me was assigning Ctrl+K to another command, then removing it again. I'm not sure what that did in the background, but Visual Studio now follows my .vimrc instead of prompting for a second chord.

In case it helps anyone, here are the full steps I used.

First, remove all shortcuts that contain Ctrl+K:

  1. From the Tools menu, click Options.
  2. From the left-hand menu, click Keyboard.
  3. From the Commands list, click any command with no shortcuts assigned.
  4. In the Press Shortcut Keys box, enter Ctrl+K, but do not click Assign. The Shortcut Currently Used By dropdown will show a list of all commands containing Ctrl+K. Make a note of these commands for reference in Step 5.
  5. For each of the commands:

    1. In the Show Commands Containing box, type the command's name.

    2. From the Commands list, click the command.

    3. From the Shortcuts For Selected Command dropdown, click each shortcut that contains Ctrl+K and then click Remove to remove it.

  6. Click OK to save the changes.

Next, assign Ctrl+K to a command and then remove it again:

  1. From the Tools menu, click Options.
  2. From the left-hand menu, click Keyboard.
  3. From the Commands list, click any command with no shortcuts assigned.
  4. In the Press Shortcut Keys box, enter Ctrl+K, and then click Assign.
  5. From the Shortcuts For Selected Command dropdown, click the Ctrl+K shortcut and then click Remove.
  6. Click OK to save the changes.

Now try using Ctrl+K. It should behave according to your .vimrc.

This works for me. Thanks a lot!

Works for me too! One million thanks!

It works for me (VS2017). Thanks!!

To summarize the reason this issue is open: in a perfect world, using the workaround suggested by @dHeinemann would not be necessary.

I experienced the same problem today when I installed VsVim (v 2.1.1.0) in VS 2015 for the first time. My .vimrc uses Ctrl+K and Ctrl+J to scroll up and down:

nnoremap <C-k> 2<C-y>
nnoremap <C-j> 2<C-e>

Ctrl+J worked after setting VsVim to handle all its shortcuts. Ctrl+K didn't work despite telling VsVim to handle it.

I tried removing all the Ctrl+K shortcuts like @jazzdelightsme suggested, but that didn't resolve the problem for me. Visual Studio continued to prompt for a second chord when using Ctrl+K.

What finally resolved the problem for me was assigning Ctrl+K to another command, then removing it again. I'm not sure what that did in the background, but Visual Studio now follows my .vimrc instead of prompting for a second chord.

In case it helps anyone, here are the full steps I used.

First, remove all shortcuts that contain Ctrl+K:

  1. From the Tools menu, click Options.
  2. From the left-hand menu, click Keyboard.
  3. From the Commands list, click any command with no shortcuts assigned.
  4. In the Press Shortcut Keys box, enter Ctrl+K, but do not click Assign. The Shortcut Currently Used By dropdown will show a list of all commands containing Ctrl+K. Make a note of these commands for reference in Step 5.
  5. For each of the commands:

    1. In the Show Commands Containing box, type the command's name.
    2. From the Commands list, click the command.
    3. From the Shortcuts For Selected Command dropdown, click each shortcut that contains Ctrl+K and then click Remove to remove it.
  6. Click OK to save the changes.

Next, assign Ctrl+K to a command and then remove it again:

  1. From the Tools menu, click Options.
  2. From the left-hand menu, click Keyboard.
  3. From the Commands list, click any command with no shortcuts assigned.
  4. In the Press Shortcut Keys box, enter Ctrl+K, and then click Assign.
  5. From the Shortcuts For Selected Command dropdown, click the Ctrl+K shortcut and then click Remove.
  6. Click OK to save the changes.

Now try using Ctrl+K. It should behave according to your .vimrc.

Huge thanks for this, I was going to get settled without Ctrl+k but seems like I don't have to anymore. 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mfrischknecht picture mfrischknecht  路  6Comments

jaredpar picture jaredpar  路  5Comments

LariscusObscurus picture LariscusObscurus  路  4Comments

iamkarlson picture iamkarlson  路  7Comments

myopicmage picture myopicmage  路  5Comments