Re: Block Indent

With the standard Visual Studio editor, I can select a block of text and hit Tab to tab the entire block over to the right (or shift-tab to move to the left).  How can I do this with ViEmu ?

Great product, btw!


Re: Block Indent

Ejay, thanks for the kind comment.

There are two main ways - using operator '>' (or '<' to unindent) followed by a motion, or entering visual mode and using the operator too.

As an example of the first way, if you want to indent 3 lines, you could use >2j which will apply the indent operator to the range from the current position to the line two lines below the current one (2j).

Other motions could prove more useful: if you are at the opening brace of a C-like function (blocks delimited by '{'), >][ will indent from here to the first line below which starts with a closing brace (the motion denoted by ][).

Also, if you are inside a brace-delimited block, >iB will indent the block (w/o including the braces), and >aB will indent the block including the braces.

The second way, visual mode, is very useful and interesting to know. Press 'V', and ViEmu (or vim, but not the pure, original vi) enters visual-lines mode. Move around like normal, lines will be highlighted. Now press '>' and the operator will be applied on the highlighted range, indenting it. If you pressed 'd', the delete operator would be applied on this range (deleting it and copying it to the default register/clipboard).

If you use 'v' to enter insert mode, this highlights a character range (not a lines-range). Also, ctrl-v enters block-visual mode, which highlights a block of text (very useful for manipulating column-structured data).

Let me know if you need anything else!




Re: Block Indent

Another tip... I tend to use enter visual mode if I have ANY doubt that the movement will do exactly what I want. That way I can see what my edit command is going to affect before I actually do it. (For example, rather than hitting '>}' to indent a paragraph, I might hit 'V}' first, then maybe adjust before hitting '>'.

How bout block comment/uncomment? In Visual Studio I select a region and press Ctrl-K, c (or Ctrl-K, u to uncomment). I can do that if I configure ViEmu to use Visual Studio selection in visual mode, but I don't like the cursor positioning during selection when I do that.

(By the way, you said something about entering insert mode with 'v' when I think you meant visual selection mode.)


Re: Block Indent

Great, I'll give it a shot.  Thanks for the prompt response.


Re: Block Indent

You're welcome. Let me know if you stumble into anything else.


Re: Block Indent

Hi guys,

I installed the trial today as I use VIM a lot at home, and I'm keen to use this as much as I can in the next 30 days to get a good idea of how productive it's going to be for me.

So far I'm impressed smile

At the mo I'm having an issue with block commenting. With the plugin enabled, I can't use CTRL-K,C like I would normally, and toggling the "use Visual Studio selection in visual mode" doesn't do anything.

Am I doing something stupid? What's the best/quickest/easiest way to retain the block comment/uncomment functionality?

Many thanks.

EDIT: I have also tried the method of using block visual mode (that is: V,},I,//,ESC) but that doesn't work either.

Last edited by TheColonial (2007-05-21 01:48:18)


Re: Block Indent


The only reason the first option you mention seems not to work in my installation is because the proper sequence is "Ctrl-K, Ctrl-C" (both with Ctrl-). You need to have the ViEmu setting "Use Visual Studio selection in visual mode" activated for this to work, though.

The second option you mention ("V}I//<esc>") doesn't work because 'I' doesn't work for visual-lines selection. It will work if you use visual-block selection (with Ctrl-Q, or Ctrl-V if you disable its default 'paste' binding).

Since I prefer to use ViEmu's emulated selection, I use the second method myself (using visual-block mode).

Let me know if any other issue comes up.




Re: Block Indent

Hi Jon,

Thanks for the response. The first option didn't work for me. As mentioned in my first post, activating this option didn't change the behaviour.

I'd rather not change the default CTRL-V behaviour as it is a bit of a habit of mine to use it for pasting. I didn't realise that CTRL-Q behaved in the same way though, and by the looks of it that's solving the problem for me.

Thanks for the great feedback!


Re: Block Indent


It's weird that Ctrl-K,Ctrl-C doesn't work. You can check whether it works with ViEmu disabled (Ctrl-Shift-Alt-V to toggle it on/off) to try to see what's happening (not all language services support the comment). If it works with ViEmu disabled and not with ViEmu enabled, it's possibly because it's being removed by ViEmu's keybinding management - go to Tools|Options|ViEmu->Keyboard, and please paste the contents of the two lists and the "Keys Scanned" list here (you can select and copy the text).

You can also try to add the binding (Ctrl-K,Ctrl-C is by default bound to Edit.CommentSelection, but it's probably missing in your installation).

If you let me know what VS version you are using too, and with the information above, I can provide more feedback and/or detailed instructions to get it back working.

Best regards,



Re: Block Indent


I use VS 2005, and for some reason the normal shortcuts don't work. I don't have any other plugins installed. If i turn off the ViEmu plugin it works fine.

It's ok as far as I'm concerned, as it's forcing me to use VIM specific stuff rather than VS specific.

I'm happily using CTRL-Q smile



Re: Block Indent

Glad you prefer to use other methods, but I'm certainly puzzled because it works perfectly here. What language are you using? It might well make a difference.


Re: Block Indent

One thing I'm missing with the indent is being able to do multiple indents at once.

I commonly do something like 3:>>> which would expand out to .,+2>>> and indent the 3 lines 3 times in vim.

It's not a show stopper though because I can always just hit . after indenting once.


Re: Block Indent

Hi Colin,

I didn't even know about the multiple '>'s to indent more than once. I will take note of that and let you know when I implement.




Re: Block Indent

Cool, thanks.


Re: Block Indent


I'm having the same issue with CTRL-K, CTRL-C for block commenting. When ViEmu is disabled, it works as expected. When ViEmu is enabled, it doesn't work (says that "the key combination ... is not a command".)

I've got the "Use VS selection for Visual mode" option checked. This is the contents of my keybinding windows:

Saved Keybindings:
Edit.MakeLowercase=Text Editor::Ctrl+U
Edit.SwapAnchor=Text Editor::Ctrl+K, Ctrl+A||Text Editor::Ctrl+E, A||Text Editor::Ctrl+E, Ctrl+A
Edit.GotoBrace=Text Editor::Ctrl+]
Edit.DeleteHorizontalWhiteSpace=Text Editor::Ctrl+K, Ctrl+\||Text Editor::Ctrl+E, \||Text Editor::Ctrl+E, Ctrl+\
Edit.ClearBookmarks=Text Editor::Ctrl+B, C||Text Editor::Ctrl+B, Ctrl+C
Edit.ToggleBookmark=Text Editor::Ctrl+K, Ctrl+K||Text Editor::Ctrl+B, T||Text Editor::Ctrl+B, Ctrl+T
Edit.NextBookmark=Global::Ctrl+K, Ctrl+N||Text Editor::Ctrl+B, N||Text Editor::Ctrl+B, Ctrl+N
Edit.PreviousBookmark=Global::Ctrl+K, Ctrl+P||Text Editor::Ctrl+B, P||Text Editor::Ctrl+B, Ctrl+P
Edit.CharTranspose=Text Editor::Ctrl+T
Edit.ViewWhiteSpace=Text Editor::Ctrl+R, Ctrl+W||Text Editor::Ctrl+E, S||Text Editor::Ctrl+E, Ctrl+S
Edit.FormatSelection=Text Editor::Ctrl+K, Ctrl+F||Text Editor::Ctrl+E, F||Text Editor::Ctrl+E, Ctrl+F
Edit.ToggleTaskListShortcut=Text Editor::Ctrl+K, Ctrl+H||Text Editor::Ctrl+E, T||Text Editor::Ctrl+E, Ctrl+T
Edit.ToggleWordWrap=Text Editor::Ctrl+E, Ctrl+W||Text Editor::Ctrl+E, W

Clashing Keybindings:
View.CodeDefinitionWindow=Global::Ctrl+W, Ctrl+D
View.TaskList=Global::Ctrl+W, Ctrl+T
Debug.QuickWatch=Global::Ctrl+D, Ctrl+Q
View.ErrorList=Global::Ctrl+W, Ctrl+E

ViEmu 2.1.17. VS 2005 8.0.50727.762 (SP.050727-7600)

Any ideas?


Re: Block Indent

hereschenes, can you go to Tools|Options|Keyboard and verify if Edit.CommentSelection is assigned to some shortcut? Just type the command name and the drop-down should show the assigned keys. If it's not assigned to anything, can you try to Ctrl-K,Ctrl-C manually? This should fix the problem.

I don't really know why it might have gotten removed. If you want, we can also try to reset and re-analyze clashing keybindings from scratch for a better understanding (it's slightly a longer procedure).




Re: Block Indent

Hi Jon,

Thanks for that. Assigning it manually does indeed fix the problem (I had to do the same thing for the 'uncomment selection' command Ctrl-K, Ctrl-U). One thing though, if I disable ViEmu, and then reenable it again, the keybindings disappear and I have to manually reassign them again. Not a big issue for me personally as I'll leave ViEmu enabled most of the time, but it seems odd. Let me know if there's anything else I could investigate!



Re: Block Indent

To fix that, do the following:

1) Go to Tools|Options|ViEmu->Keyboard
2) Click 'Restore' under the left-hand-side list (answer yes to the confirmation dialog)
3) Click 'Forget' under the left-hand-side list (also answer yes)
4) Exit the Tools|Options dialog (ensure some VS caches are flushed)
5) Do the assignments for Ctrl-K, Ctrl-C and Ctrl-K, Ctrl-U
6) Exit Tools|Options again
7) Go to Tools|Options|ViEmu->Keyboard, and click 'Save and Remove' under the right-hand-side list (answer yes to the confirmation prompt)

After this, everything should be ok. If not, there is indeed a bug in ViEmu's keybinding handling, so please let me know.




Re: Block Indent

Thanks Jon, following those steps appears to have fixed things! smile


Re: Block Indent

Great to hear that, thanks for letting me know!