1

Re: Remapping paragraph move in viEmu under VS2005 with Visual Assist X

I am a new viEmu user (still in trial), and long-time Visual Assist user.  I miss my "wrap selected text in {}" feature on the { key.  How would I go about remapping paragraph move forward/back from { and }, to control-[ and ] ?

--andy

PS -- I'm a long-time vi user (since 1984 or so), use vim on a regular basis as my "other" text editor on windows, and it took only about 30 seconds of using viEmu in VS2005 to be totally sold on the productivity gain.

2

Re: Remapping paragraph move in viEmu under VS2005 with Visual Assist X

Hi Andy,

Thanks for the kind comment. Can you explain what the Visual Assist "wrap" feature is in detail, and how it works? I can't totally understand your request. I think a detailed explanation will help. I do have Visual Assist and test with it often (although I'm not too much into actually using it), but mainly I'm not familiar with its more advanced features.

I'll be happy to look into the issue as soon as I can understand it. I'm in "fix-minor-issues" mode now, so hopefully it won't be difficult to address it shortly.

Regards,

  Jon

3

Re: Remapping paragraph move in viEmu under VS2005 with Visual Assist X

For example, with viemu turned off,

highlight "entire line" containing statement:

if (condition)
  statement;

tap {.

VAX rewrites this to be:

if (condition)
{
  statement;
}

Similar things work with whatever is highlighted when / * ( { and # are pressed.  (Visual Assist Options, Advanced, General, "Surround selection on / * ( { and #", [ON].)

4

Re: Remapping paragraph move in viEmu under VS2005 with Visual Assist X

Hi Andy,

Now I understand. Possibly, if just passing "{" through addresses it, it could be fix with a mapping like:

  :vnoremap { gSi{<esc>

Which means: in visual mode, map "{" to gS (convert current ViEmu visual range to Visual Studio selection), enter insert mode ( similar to a pass-through), pass "{" on, and return to normal mode.

Making <c-[> and <c-]> work as the original { and } should be as simple as:

  :vnoremap <c-[> {
  :vnoremap <c-]> }

As long as <c-[> and <c-]> aren't bound to anything by Visual Studio. You can use ":noremap" for completeness, so that they also work in normal mode.

I will investigate this myself though to see what I can come up with.

Regards,

  Jon

5

Re: Remapping paragraph move in viEmu under VS2005 with Visual Assist X

Hi Andy,

Now I understand. Possibly, if just passing "{" through addresses it, it could be fix with a mapping like:

  :vnoremap { gSi{<esc>

Which means: in visual mode, map "{" to gS (convert current ViEmu visual range to Visual Studio selection), enter insert mode ( similar to a pass-through), pass "{" on, and return to normal mode.

Making <c-[> and <c-]> work as the original { and } should be as simple as:

  :vnoremap <c-[> {
  :vnoremap <c-]> }

As long as <c-[> and <c-]> aren't bound to anything by Visual Studio. You can use ":noremap" for completeness, so that they also work in normal mode.

I will investigate this myself though to see what I can come up with.

Regards,

  Jon

6

Re: Remapping paragraph move in viEmu under VS2005 with Visual Assist X

Andy,

I just researched this. Using 'i{' doesn't work, because ViEmu doesn't simulate a keypress, which is what Visual Assist hooks to.

Fortunately, Visual Assist provides the functionality with the command name "VAssistX..SurroundSelectionWithBraces". You can use this from a ViEmu mapping, using the ViEmu ":vscmd" ex command, to access the functionality.

Here is a mapping you can use to restore the functionality:

  vnoremap { gS:vscmd VAssistX.SurroundSelectionWithBraces<return>

This maps '{' in Visual mode to gS (convert ViEmu visual range into VS's selection), typing the ex command, and pressing return.

You can put this in _viemurc or .viemurc in your home directory (either "C:\Documents and Settings\{username}" or "C:\Users\{username}" in Vista) to have it available every time.

Regards,

  Jon

7

Re: Remapping paragraph move in viEmu under VS2005 with Visual Assist X

Thanks, Jon.  I'll apply that change when I return to work on Monday.  And thanks for the tip about where to store startup-related settings and commands.

--andy

8

Re: Remapping paragraph move in viEmu under VS2005 with Visual Assist X

Good, you're very welcome, let me know how it works for you. I'm hoping to release 2.2 this coming week with a few more improvements.

Regards,

  - Jon

9

Re: Remapping paragraph move in viEmu under VS2005 with Visual Assist X

This: vnoremap { gS:vscmd VAssistX.SurroundSelectionWithBraces<return>

Doesn't work flawlessly for me. Tried on two different computers, Vista and XP, VS2005 and 2008, two different versions of VAssistX.

To reproduce: Select a single line, or just a word, in whichever selection mode you like. Press {. You will get something like:

{                    line; }

If you select the same line, then press gS, then finally right-click on the selection and choose surround by braces from the menu instead, you will get:

{
     line;
}

My two cent analysis is that something happens to the visual studio selection when you press : in visual mode. Could this be correct?

10

Re: Remapping paragraph move in viEmu under VS2005 with Visual Assist X

Tomas,

What setting do you have in Tools|Options|ViEmu "Use VS selection for Visual Mode"? Even if you have a ViEmu visual selection, unless you check this checkbox, VS doesn't see any selection. The ViEmu visual range is just a marker for Visual Studio. gS actually converts this to the VS selection, so that VS can act on it.

The above explanation will be easier to understand for me if you say what you mean exactly when you say "select", and the value of the setting.

Interactions between third-party add-ins are really difficult, especially in difficult areas like visual selection.

Regards,

  - Jon

11

Re: Remapping paragraph move in viEmu under VS2005 with Visual Assist X

Hi Jon,

I understand that this is the case. My "Use VS selection for Visual Mode" is off. However, if you read a little more closely, you'll see that the mapping I was talking about starts with a gS, like so:

vnoremap { gS:vscmd VAssistX.SurroundSelectionWithBraces<return>

I will slightly rephrase my reproduction:

To reproduce: Select a single line, or just a word, in whichever ViEmu selection mode you like. Press { as per the vnoremap above. You will get something like:

{                    line; }

If you select the same line using ViEmu, then press gS, then finally right-click on the selection and choose surround by braces from the menu instead, you will get:

{
     line;
}

I hope that makes it clearer.

12

Re: Remapping paragraph move in viEmu under VS2005 with Visual Assist X

Tomas,

Apologies for not coming back to you earlier about this. I haven't been able to test this properly until now.

I have been testing it now, and, frankly, I think this is not an issue with ViEmu. As far as I can tell, the difference in behavior lies with Visual Assist. If you right click and then select "Surround With", they have a different behavior that if the "VAssistX.SurroundSelectionWithBraces" command is sent. You can check that this also happens without ViEmu: the non-VS way to issue a VS command is to go to the QuickFind field, and type the name with ">" prepended.

Thus, w/o ViEmu at all (or with it disable), you can just select whatever you want, and try these two ways of surrounding it with braces:

- Click on the QuickFind box in the standard toolbar, type >VAssistX.SurroundSelectionWithBraces, and press return

- Right-click on the selection, and select "Surround With" there, then select braces.

The operations show the difference you describe. There is nothing I can really do there.

I know ViEmu's scriptability, configurability and integration are limited, and I could provide much more sophisticated methods, but the difference you mention is nothing I can change.

Regards,

  -- Jon

13

Re: Remapping paragraph move in viEmu under VS2005 with Visual Assist X

I've already replied privately, but for the record I want to say that Jon is absolutely correct. This is a VAX issue and nothing to do with ViEmu.

14

Re: Remapping paragraph move in viEmu under VS2005 with Visual Assist X

Thanks for confirming it, Tomas!

  - Jon