Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's so great about Block Selection Mode?

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!

like image 852
Xanatos Avatar asked Sep 03 '10 21:09

Xanatos


2 Answers

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.

like image 58
FrustratedWithFormsDesigner Avatar answered Oct 02 '22 20:10

FrustratedWithFormsDesigner


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.

like image 41
Tom Anderson Avatar answered Oct 02 '22 20:10

Tom Anderson