An Oracle blog about NetBeans for PHP

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? 

Join the discussion

Comments ( 14 )
  • GaryJ Thursday, October 20, 2011

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

  • guest Thursday, October 20, 2011

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

  • William Rouse Thursday, October 20, 2011

    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.



  • guest Friday, October 21, 2011

    Great !

  • Petr Pisl Friday, October 21, 2011

    @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.

  • SeanR Friday, October 21, 2011

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

  • Tom Monday, October 24, 2011

    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.

  • Jon Tuesday, October 25, 2011

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

  • David Friday, October 28, 2011

    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.

  • mike Sunday, November 27, 2011

    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.

  • Petr Tuesday, November 29, 2011

    Please file an issue against editor infrastructure to be user able to customize this action. http://netbeans.org/community/issues.html


  • guest Monday, April 23, 2012

    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.

  • Thomas Monday, March 25, 2013

    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.

  • Snow Thursday, January 9, 2014

    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.

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.