views:

64

answers:

4

Longtime Eclipse user here; I recently discovered the "Block Selection Mode" (Alt-Shift-A) that was added into Eclipse 3.5. I tried it out, it's pretty neat--I can select a rectangle of text in my source code instead of selecting things a line at a time like I usually do.

Apparently this feature is common in other editors too, under other names like "column edit mode", etc. A lot of people seem to really love it, but I've got by without for a long time.

So my question is: What kinds of things is this feature useful for?

The only one I can think of is inserting a comment characters (like // or #) in front of a chunk of text. Also, I supposed if I had a bunch of variables names that were all lined up and I wanted to change the first characters for all of them at once. But surely there's more to it than that? I mean, when it comes to choosing an editor, this feature is apparently a deal-breaker for some people!

A: 

If you are looking at a file with fixed width fields, sometimes you only want to select one column.

Byron Whitlock
+1  A: 

I find it is very useful when working with fixed-position field data files, and you only want to select a few fields for search-replace or copy-paste. It is also good for things like this:

call_foo('A',123);
call_foo('B',143);
call_foo('C',331);
call_foo('A',113);
call_foo('R',789);

The code is all the same except for some characters in some columns. You could select a block around the second parameter and search for the line containing 113. Useful when you have more than just a few lines all together in this format.

FrustratedWithFormsDesigner
Not to mention, select ''_f' and change it to 'F' in a heartbeat. Though in general I think it's much less useful in Eclipse than in a plain text editor. Coding Java in Eclipse you'd just refactor the method name. But when I code in Perl for example, I use UltraEdit, and the column editing saves me a ton of time.
Matthew Smith
Ah yes good point. I do Java and Python in Eclipse, and I can see what you mean--it would be handier in Python where the refactoring tools aren't as fully developed yet.
Xanatos
A: 

A colleague of mine told me of a project where they wrote JDBC code like this:

String query =
    "select question, answer, accepted " +
    "from so_answers                   " +
    "where poster = 'Jon Skeet'        " +
    "order by upvotes                  ";

So that they could block-select the SQL in order to paste it into a database tool and run it by hand. Seems a bit barmy to me, but it evidently worked for them.

Tom Anderson
Maybe they should try SquirrelSQL, which can add and remove Java style quoting to/from statements.
Chris Lercher
A: 

If you arn't using a block cut/copy/paste operation at least four or five times a day then I would suggest you're just doing a lot of extra typing.

Blake7