开发者

What's so great about Block Selection Mode?

开发者 https://www.devze.com 2023-01-14 04:21 出处:网络
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 s

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 varia开发者_StackOverflowbles 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!


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.


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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消