1

Re: Help with keyboard mapping?

Hi folks,

I've just installed the latest ViEmu I could find (2.5.11)

It's been a while since I used ViEmu (due to the lack of VS2010/R# support) and there are some Resharper shortcuts I've got used to that I'd rather not live without. 

After a bit of research I've managed to get some of the behavior I'm after by mapping more keys to ViEmu and setting up mappings in my _viemurc

It is currently as follows:
map <A-j> :vsc Resharper.ReSharper_GotoNextHighlight<CR>
map <A-k> :vsc Resharper.ReSharper_GotoPrevHighlight<CR>
map <A-i> :vsc Resharper.ReSharper_Generate<CR>

The problem is there is one mapping I'd love to get working but can't figure out exactly what I need to do.  What I'm trying to do is get Ctrl+E,U to execute Resharpers Surround With Template when in visual mode.

I've tried enabling the option for "Use VS selection for Visual Mode" along with the following mappings:
vnoremap <C-e><u> <A-r><e><u>
vmap <C-e><u> :vsc Resharper.ReSharper_SurroundWith<CR>

But nothing works the way I'm hoping it will.

Does anyone have any suggestions on how to get this to work?

Last edited by hastarin (2010-11-30 06:44:43)

2

Re: Help with keyboard mapping?

I'm not really sure this is viable, it depends a lot on how R# does things. The first mapping (vnoremap <C-e><u> <A-r><e><u>) definitely won't work, as ViEmu only sends keys to itself. The second (vmap <C-e><u> :vsc Resharper.ReSharper_SurroundWith<CR>) may work, but it's subject to difficulties.

You can try using the gS ViEmu command (only usable in a macro/mapping) to convert ViEmu's visual range to VS's selection, even if the "Use VS Selection" setting is off. That might help even in the latter case.

If you type ">Resharper.Resharper_SurroundWith" at the QuickFind bar, with ViEmu disabled, and with an active selection, what does R# do? That could help.

It's often difficult to get 3rd party add-ins that are developed without much regard for each other, in an environment that doesn't help with these things, to get to work together in this kind of way. If you can control R#'s functionality with a VS macro (with 0 ViEmu intervention), that could provide the best starting point to try to get ViEmu to trigger it.

3

Re: Help with keyboard mapping?

I've tried with/without gS and with/without the "Use VS Selection" option set.  Neither works.

Currently I have "Use VS Selection" set, and without gs.  So:
vmap <C-e><u> :vsc ReSharper.ReSharper_SurroundWith<CR>

If I hit that combination it just dumps me back to Normal mode.

If I do as you've suggested with the QuickFind bar and ViEmu disabled it works as expected.  In fact it works with ViEmu enabled and the "Use VS Selection" set as well.

It's not the end of the world if I can't get this working.  If I do have "Use VS Selection" set I can just use "Alt R, e, u" to access the R# shortcut and that works fine.  It just means learning the new key sequence instead of the one that's already memorized from months of use.

I'm just a bit of a perfectionist, like most of your users probably are, and would love to get this working if it's possible.  It would mean more flexibility with similar options too.

4

Re: Help with keyboard mapping?

Hello Hastarin, I am taking note of this, and we will try to investigate how we can make ViEmu, VS, and Resharper "tolerate" each other enough to make this work. I'm sorry, it's often difficult to make a model as different as vi/vim's coexist with VS and R#, which have been written without taking anything like vi/vim into account.