Re: Reworked Keyboard Mapping In ViEmu 2010

I have just upgraded to ViEmu 2010 and have been trying to work with it today in Visual Studio 2010 and am having all sorts of problems with the keyboard mapping. I went to the Tools menu, but there is no longer anything there. I went to Tools | Set Keybindings... but see I can no longer see what the bindings are or change them in any way. All that menu click does is to tell me the bindings for ViEmu have been installed.

I have also spent a LOT of time this afternoon going to the Tools | Options | Environment | Keyboard dialog where I have tried to fix the mappings I am having trouble with, but it seems sort of like the changes I make do not stick for long.

The general problem I have is that it seems like I can no longer do anything using regular VS and standard MS keyboard shortcuts like Cntrl-C (copy), Cntrl-V (paste), etc. I have LOVED using the product in VS 2008 because it gave me the best of both worlds, seamlessly... I could us vi commands or I could use Ctl-C, Ctl-V, etc. Now it seems all I can do is use vi commands.

I hope this is just a learning curve on my part. It looks like until I find out how to fix this issue, I won't be able to use ViEmu as it keeps me from doing my work.

Please advise.




Re: Reworked Keyboard Mapping In ViEmu 2010

Hello Brad, sorry about the issues. Indeed, the input system in ViEmu for VS2010 has been reworked. The techniques we used in the older ViEmus weren't available in VS2010, as the editor it has is completely new, and it is done using WPF instead of ole' Win32 Windows. So there could be some issues to get things working to your taste again. The good news is that it's possible.

In VS2010, the way ViEmu receives input is much more aligned with "the VS way" of doing things. That means that the best way you can check and change what a keypress does is just to go to Tools|Options|Environment|Keyboard. For example, if you want Ctrl-C to copy, press Ctrl-C in the keypress window there, and make sure it is assigned to "Edit.Copy" instead of "ViEmu.KeypressCtrlC". This represents where the keypress goes.

One possible "gotcha" in that window is that VS actually maintains different mappings for different "scopes", and you can assign a function to a keypress in one context, and another function in another context. The relevant scopes for text editing are "Text Editor" and "Global". When editing text, VS first checks the "Text Editor" scope and applies it, and if it doesn't find any assignment there, then it checks the "Global" keybinding and uses that instead. So make sure you are editing the right one and checking for conflicts! This is a bit confusing, but this is just the VS side of things (and not-very-clear UI). With this, you should be able to assign Ctrl-C/Ctrl-V and other similar keypresses to your desired functions. ViEmu sets them in the way the majority of users want, but of course we know that different people have different tastes and we provide the customizability.

One other thing that might bite you is the distinction between ViEmu's "visual range" and VS's selection. By default, ViEmu uses its own highlight mechanism to implement visual mode range display. If you select two lines Vj, by default this won't change VS's selection. If you use Ctrl-C now, even if it has been mapped to "Edit.Copy", it won't copy that region, because as far as VS knows, there is no text selected. If you want to use Ctrl-C/Ctrl-V and other non-ViEmu actions seamlessly, the best is that you go to ViEmu|Settings and enable the "Use VS selection for visual mode" option. The only drawback is that visual range will be a little less faithful this way, but interoperability will be better. For those of us that stick to mostly ViEmu operations most of the time, this is a better option, but of course, may people choose to do it the other way around.

I hope that you will be able to configure ViEmu to your liking, and please post again if anything else acts up! VS is a complex beast, and integrating something as different as vi/vim editing is always a challenge. Together with the fact we had to rewrite over half of ViEmu for VS2010 (the floor changed under our feet!), it's taking a bit of an effort to transition, but all should be good once configured correctly.


  -- Jon