Rectangular Selection

If you use development build, you probably noticed that NetBeans editor added Rectangular Selection action. I don't need this functionality every day, but it can be helpful in some case. One of such case is when you need to delete line numbers in a text  or code copied from  a tutorial. Like on the picture below.

You can select the rectangle after pressing Rectangular Selection toggle button in the editor toolbar or pressing CTRL+SHIFT+R shortcut. 

The selection can be easily done with mouse or keyboard. When you use keyboard, just place the caret on a corner, keep down SHIFT  and with the arrows keys you select what you need. 

When the selection is done, you can easily delete all the line numbers with pressing DELETE key. Then you have to exit from the rectangle selection mode (CTRL+SHIFT+R or toggle button in the editor toolbar).

If you write a text , then the text is placed on every line in the selected area. This can be useful for example for changing access modifiers of more fields in a class at once. 

Do you use the rectangular selection? For which cases? 


Excellent addition - one less reason for me needing a separate text editor alongside Netbeans.

Posted by GaryJ on October 20, 2011 at 12:21 PM CEST #

I have waited for this feature for so long! Excellent work!

Posted by guest on October 20, 2011 at 02:06 PM CEST #

I don't use this every day but I find that I need this more often than an editor provides. I have learned to call this a column (or columnar) cut, if I understand this feature correctly and I am glad this is provided. I expect to see this in the next release, is that correct.

Posted by William Rouse on October 20, 2011 at 11:37 PM CEST #

Great !

Posted by guest on October 21, 2011 at 04:44 AM CEST #

@William: Yes, the feature is a part of NetBeans 7.1, that is almost done, we are in fixing phase and a few weeks before releasing.

Posted by Petr Pisl on October 21, 2011 at 05:30 AM CEST #

It's about time. Netbeans is one of the last to get this functionality, but hey, I am glad we finally get it!

Posted by SeanR on October 21, 2011 at 10:42 AM CEST #

Yes! Good thing.

Even though the key binding is a bit odd. All editors I have worked with (PSPad, ConTEXT, PlainEdit and others) have the ALT-key for rectangular selection. Editors are pretty consistent with this binding and people may be used to it.
Just press and hold ALT and mark the text using the mouse. I guess this is the most user-friendly way to do it.

The additional binding to permanently switch to a "rectangular/column selection mode" is more for handicapped people, who can't hold down a key and use the mouse at the same time. (Or for rare situations, where you don't have a mouse)

And @William is right: all other editors I know use the wording "column mode" or "column select", even though the original Netbeans plugin was called "rectangular selection". But this is minor.
The term "column select" comes more natural when you know that some editors have a "row select" mode, too.
If you think of CSV-files this wording makes a lot of sense.

The common place where other editors put that feature is the "edit" menu, where you will find something like a "selection mode" or "toggle select mode" entry.

One thing that the examples above don't show is text-selection behind the EOL-character(s). An obviously required feature for rectangular selection to work properly, since you want to be able to select a block (or "column") where some lines may be empty or shorter than others.

Like when you wish to only select the variable names in this case:

* int $abc
* string $d
* int $ef

Or when selecting the last column of a CSV-file.

I use rectangular selection for situations where I'm too lazy to write a reg-ex. Like selecting filenames after a ls or dir command, for log-files, fixed-width CSV-files, or quickly writing tons of similar SQL-statements (via column/rectangular edit) aso.
Not an everyday job, but once a week or so.

Posted by Tom on October 24, 2011 at 08:07 PM CEST #

Rectangular selection is very useful. Every decent editor has it.

Posted by Jon on October 26, 2011 at 12:44 AM CEST #

Finally! It's a very useful feature, I regularly use it in JEdit mainly for occasions where I need to edit similar text in multiple lines at the same time like array definitions, SQL statements etc.

I agree with @Tom though, it would be much more user friendly to be able to make a rectangular selection by simply pressing a modifier key like ALT or CTRL and dragging the mouse.

Posted by David on October 28, 2011 at 09:22 AM CEST #

I love this feature! I use it in notepad++. Can you change the shortcut to where you hold down alt and then drag with the mouse? And when you let go of the mouse it should let you type and then after clicking else where it should be out of this mode.

Posted by mike on November 27, 2011 at 01:42 AM CET #

Please file an issue against editor infrastructure to be user able to customize this action.


Posted by Petr on November 29, 2011 at 02:34 AM CET #

For me, this is key functionality for my day to day life. As per convention, we had to align the the '='s of assignments in a code block. I had to 'tab' each '=' when a newly introduced statement exceeds the previous alignment to cope with the new statement. Now, I just have to drag the line vertically along the '=' and give a single tab to vertically align all statements at once. Great addition to Netbeans.

Posted by guest on April 23, 2012 at 02:58 PM CEST #

A very useful feature, although it can be confusing if you haven't heard about it before and press it by accident in the toolbar. Tanks for positing it - I now managed to switch it off again.

Posted by Thomas on March 25, 2013 at 02:44 PM CET #

I was used to it when modifying data which should become csv-convenient.

Sometimes the amount is just too much to do it simply by tapping the keys,
but not large enough to create a specific routine to handle the problem.

Posted by Snow on January 09, 2014 at 01:18 PM CET #

Post a Comment:
  • HTML Syntax: NOT allowed

This blogs is written by NetBeans developers who contribute to the PHP support mainly.


« September 2016