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).

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

Re: Block Indent

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

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.OJ

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

Re: Block Indent

Hello,

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).

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.

Re: Block Indent

Ok,

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.

Re: Block Indent

Re: Block Indent

Hi,

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:

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->Keyboard2) 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-U6) Exit Tools|Options again7) 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.