1

Re: Visual block and indentation

Good day

I have a little bit of a trickier enhancement / compatibility request...

If you have a block of text and you visual block select on a part of the text at a point not at the beginning of the line, eg, in the text below, visual block selecting the "ll"'s in "hello":

hello world
hello world
hello world

and then indent (or outdent), using ">" (or "<" respectively), then vim will indent / outdent the text to the right of the start of the selection block, resulting in (with the above text and the case of an indent):

he  llo world
he  llo world
he  llo world

Outdenting after selecting the "ll" column again will close the gap, but, of course, not allow further outdenting past that since to do so would result in the "ll" column overwriting something to the left of it.

I would REALLY appreciate the inclusion of this compatibility feature because it's really useful to use block select to do something like convert:

    double mdblMinY;
    double mdblMaxY;
    double mdblLatestY;
    double mdblTotalY;
    double mdblAverageY;

to

    double mdblDataMinY;
    double mdblDataMaxY;
    double mdblDataLatestY;
    double mdblDataTotalY;
    double mdblDataAverageY;

by first indenting from after the "mdbl" parts and then using visual block select and 's' to replace the blank column with "Data". I don't know if there's a better way to do this in vim -- this is just the way that I'm used to doing it and it's not an uncommon thing for me to do with my text.

2

Re: Visual block and indentation

I seem to remember implementing > and < over block regions the same as for other types of regions, by indenting full lines. I also seem to remember that I did it this way because vim worked like that for me. But I just checked and you are right, gvim works the way you say!

I think it must be another case of "the default config of gvim on windows" being different from the default on other systems (as Ctrl-V pasting instead of going to block-visual mode). I turned all Windows-specific features some time ago, and that's probably why it now works like you say for me.

I'm taking note of this request, it's not trivial (like the % issue) and I have to prioritize other things ahead of this. Anyway, I would advice you to use the vim-natural way of doing this, which I call "column-multi-input", and which ViEmu fully implements:

If you block-select the column after 'mdbl' in the first example (the one containing MMLTA, the first letter each of the proper variable names after the hungarian prefix), and press 'I', you will go to a special insert mode. You can type 'Data' here, and when you press ESC, this will be replicated on the other lines.

You can also use s and A for this purpose - 's' will substitute what is selected, and A will append. If you do <ctrl-v>jjjjj    to select a few lines, then A and type something, what you append will be copied to the end of all lines (not lined up, but to the end of each line), which is pretty useful too. And as a subtle case, I and A also difer in that I will skip lines which contain no characters where the block is (such as empty lines), while A will autocomplete with spaces.

3

Re: Visual block and indentation

I would advice you to use the vim-natural way of doing this, which I call "column-multi-input"

I wouldn't really call this "natural", because it requires extra keystrokes, but it works.

However, it doesn't address block unindent, which is the more useful feature. I use this all the time. Let's say I had the following text, and I wanted to line up the word 'text':

   this text
   have the word text in various
   positions, in all it's text glory

I can use a quick":s" to insert some space before the word "text" resulting in:

   this                         text
   have the word                         text in various
   positions, in all it's                         text glory

Now (in Vim) I can just draw a vertical column where I want them to line up, hit <, then tap . a few times. Resulting in a neat column:

   this                    text
   have the word           text in various
   positions, in all it's  text glory

This feature (block indent/unindent) and the lack of virtual selection are two of the main reasons I'm forced to shell out to Vim from within ViEmu.

Virtual selection allows one to originate columns like my example above. If you extend a column selection past the end of some lines with virtual selection enabled, it squares-off the end of the selection. You then press A and append a nice, neat column, regardless of how uniform the lines you're appending to are.

To me, these kind of actions -- sophisticated text manipulation -- are the heart of what make Vim useful. I'd love to see them more accurately supported in ViEmu some day.

Last edited by Eric Tetz (2011-04-03 01:07:44)

4

Re: Visual block and indentation

Thanks again for the suggestions, Eric.