Bug 13857 - Cutting/Copying vertical blocks of text
Cutting/Copying vertical blocks of text
Status: RESOLVED FIXED
Product: editor
Classification: Unclassified
Component: Actions/Menu/Toolbar
3.x
All All
: P1 with 38 votes (vote)
: 7.1
Assigned To: Miloslav Metelka
issues@editor
: PLAN
: 13967 53319 57951 58644 65616 84267 98045 137089 139116 146233 150230 151731 172598 (view as bug list)
Depends on: 201689
Blocks:
  Show dependency treegraph
 
Reported: 2001-07-23 19:54 UTC by Don Kleppinger
Modified: 2014-02-05 10:11 UTC (History)
13 users (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments
Rectangular Tools for NetBeans 6.9 (29.92 KB, application/octet-stream)
2010-10-19 21:51 UTC, Michel Graciano
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Don Kleppinger 2001-07-23 19:54:11 UTC
There needs to be a way to copy/cut & paste a vertical block of text. Useful 
for table manipulation. This is a feature I use all the time in Visual Cafe but 
there is no equivalent in netbeans.
Comment 1 David Konecny 2001-07-24 09:42:58 UTC
I'm moving issue to editor module. I'm not sure what is the 
"sourceeditor" module good for. (it appeared after migration to 
SourceCast)
Comment 2 David Konecny 2001-07-26 14:24:23 UTC
*** Issue 13967 has been marked as a duplicate of this issue. ***
Comment 3 psuk 2004-03-23 18:34:20 UTC
Changing subcomponent to "clipboard"
Comment 4 _ proxity 2004-05-12 10:39:33 UTC
I'm also very interested in this feature. I've got to use Emacs if I
need it at the moment. This request is pretty old, what about defining
when it will be implemented?
Comment 5 Miloslav Metelka 2005-05-06 14:47:31 UTC
*** Issue 58644 has been marked as a duplicate of this issue. ***
Comment 6 Roman Strobl 2005-05-16 21:20:40 UTC
Recently discussed at javalobby: 

http://www.javalobby.org/java/forums/m91833403.html
Comment 7 jirkah 2006-08-11 05:24:40 UTC
*** Issue 53319 has been marked as a duplicate of this issue. ***
Comment 8 jirkah 2006-08-11 05:26:52 UTC
This would be great. See for example how this is handled in Ultraedit
(www.ultraedit.com) or WinEdt (www.winedt.com, called blocks).

I would suggest something like this:
- easy switch between line and column selection mode (Alt+C in Ultraedit, Alt +
mouse)
- possibility to search and replace just in the column selection
- possibility to replace a column by a particular string (e.g. selecting an
empty column at the begining of several lines and typing "/" twice would be
equivalent to selecting those line normally, followed by the Source > Comment
command)
- insert numbers into a column (with a starting value, increment and possibly a
leading zero)
Comment 9 Vitezslav Stejskal 2007-11-05 13:30:36 UTC
Moving to the 'other' subcomponent.
Comment 10 Vitezslav Stejskal 2008-04-07 09:34:40 UTC
*** Issue 65616 has been marked as a duplicate of this issue. ***
Comment 11 Vitezslav Stejskal 2008-06-18 11:54:13 UTC
*** Issue 98045 has been marked as a duplicate of this issue. ***
Comment 12 Vitezslav Stejskal 2008-06-18 11:54:23 UTC
*** Issue 57951 has been marked as a duplicate of this issue. ***
Comment 13 Vitezslav Stejskal 2008-06-18 11:54:59 UTC
*** Issue 137089 has been marked as a duplicate of this issue. ***
Comment 14 Vitezslav Stejskal 2008-06-18 11:55:19 UTC
*** Issue 84267 has been marked as a duplicate of this issue. ***
Comment 15 Vitezslav Stejskal 2008-06-18 11:56:05 UTC
Thanks to Sandip, there is a module that supports this on the plugin portal:
http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=1174
Comment 16 cahrens 2008-06-18 18:12:39 UTC
For those of us just using part of the NetBeans libraries in our product (the editor libsrc module), is it possible to 
get the source code for Sandip's plug-in and incorporate it into our own builds? This features has been heavily 
requested by our users.
Comment 17 simonrees 2008-07-03 22:35:50 UTC
I would love it if this feature were implemented. More than anything else. Working on it might not be sexy but the
editor really does matter.
Comment 18 _ proxity 2008-07-04 09:53:11 UTC
Use the plugin! It's called Rectangular Edit Tools and does its job very well.
Comment 19 simonrees 2008-07-05 13:58:45 UTC
> Use the plugin! It's called Rectangular Edit Tools and does its job very well.

Thanks for the tip proxity. I did download them before I posted. The Rectangular Edit Tools a great start but (in my opinion) there are two enhancements that 
would really improve their usefulness:

(a) visual highlighting of the selected (vertical) block.
(b) non-destructive paste.


Comment 20 simonrees 2008-07-05 13:58:47 UTC
> Use the plugin! It's called Rectangular Edit Tools and does its job very well.

Thanks for the tip proxity. I did download them before I posted. The Rectangular Edit Tools a great start but (in my opinion) there are two enhancements that 
would really improve their usefulness:

(a) visual highlighting of the selected (vertical) block.
(b) non-destructive paste.


Comment 21 Max Sauer 2008-07-08 10:05:06 UTC
*** Issue 139116 has been marked as a duplicate of this issue. ***
Comment 22 Petr Dvorak 2008-09-04 21:54:41 UTC
*** Issue 146233 has been marked as a duplicate of this issue. ***
Comment 23 pmaciver 2008-09-05 05:07:28 UTC
The best implementation of this that I have ever seen is in jEdit. I think if you make a 1 to 1 implementation of that
in netbeans that you will have the perfect implementation. And the activation is so simple, just hold down control and
select the area/region that you want to work on.
Comment 24 Petr Dvorak 2008-10-15 16:16:56 UTC
*** Issue 150230 has been marked as a duplicate of this issue. ***
Comment 25 faheemhameed 2008-10-24 11:50:33 UTC
I need this functionality immediately. Something like "komodo edit" or ultraedit's column mode function.
Comment 26 Vitezslav Stejskal 2008-10-30 10:45:26 UTC
*** Issue 151731 has been marked as a duplicate of this issue. ***
Comment 29 tusharvjoshi 2009-05-15 06:25:18 UTC
I tested the Rectangulat Edit Tools plugin with NetBeans IDE 6.5.1 and it works.  The issue reported by Rory is still 
there but I have a different observation.

When we click on the Java source file from Projects Panel the tool buttons get disabled but when we choose the Java 
source from the Editor tabs then the tool buttons are enabled.  

Something is going wrong when the files are opened or selected through the Projects panel.  With this issue known the 
plugin works to fulfill the need of block copy paste. 

Comment 30 tusharvjoshi 2009-05-15 06:32:18 UTC
Many users have asked for visual clue of the rectangular highlighting.  I believe this is a task which can only be done 
by tweaking the main editor selection mechanism code which will be a significant effort and will need thorough 
knowledge of the editor source.

If a dotted rectangle can be drawn, keeping the selection as it is, on top of the selection just to give a visual clue 
for the rectangular selection it will help the users and this may need relatively less effort.  
Comment 31 Miloslav Metelka 2009-05-15 15:10:49 UTC
The selection mechanism of the caret can be rewritten relatively easily - the highlighting layer will be modified. But that means that the editor should have 
two "modes" of operation (or three: normal; rectangular-selection; line-selection). There do not need to be extra actions (like copy; paste etc.) - instead the 
regular actions would work according to the current mode. So there would be a mechanism for switching of the mode and few extra actions e.g. for lines 
sorting. The truth is that the Swing's text framework (on which NB editor is based) is not line-based (it's offset-based) so the implementation is not 
straightforward but it's doable.
Comment 32 Petr Jiricka 2009-05-16 22:33:10 UTC
> But that means that the editor should have two "modes" of operation

I believe that's what other editors do too, I recall UltraEdit has a menu item "Edit -> Block Mode" (or similar), which
behaves like a checkbox and controls the behavior.
Comment 33 cpholt 2009-07-17 15:11:02 UTC
Rectangular selection/editing is the one thing I really, really miss from Visual Slick Edit.  In fact i still break out 
Slick Edit when I need that feature.  Their approach is similar to things discussed here.  Some ctrl-key toggles 'block-
select-mode'.  Right click and drag also creates a block selection.  Another feature is that with a column of text 
selected, you can type and it types in each row, similar to the Replace functionality of the plugin mentioned here, but 
inline.  Also, there are no new actions for rect-copy, etc.  just the normal copy/paste.
Comment 34 shmerl 2009-08-10 20:54:13 UTC
This is very useful functionality which I miss. It's implemented in Far Editor and Comodo. Interestingly, Eclipse didn't
have it for a long time too, and they just recently incorporated it in their 3.5 (Galileo) release. Visualizing the
selected area is a must, otherwise it's too confusing to use. It would definitely benefit NetBeans and Sun Studio to
incorporate this into the editor.
Comment 35 Vitezslav Stejskal 2009-09-23 14:20:20 UTC
*** Issue 172598 has been marked as a duplicate of this issue. ***
Comment 36 kAlvaro 2009-12-10 10:39:39 UTC
In many editors, Alt+Drag allows rectangular selection.
Comment 37 err 2010-01-10 06:44:01 UTC
A few comments of things I noticed when adding visual block mode to jVi... I haven't worked with other editors in this regard, so I have no basis for comparison.

There's some jVi usage examples of vim's blockmode at http://jvi.sourceforge.net/javahelpset/jvi-vis_block.html; they are based on and extended from Sandip's original doc's.

Of possible interest are behaviors in the presence of short lines. vim pads with spaces in some situations to keep/make a source/destination rectangular.

One complexity is TAB treatment. vim works with virtual columns and splits tabs, converting to spaces, when needed. Also, it is impossible with netbeans/swing highlighting to rectangularly display a region that slices across a tab, the vertical edge has bumps in it. jVi behaves correctly, it just displays funny.

Vim has a command, gv, to reselect the previous block acc'd to absolute coordinates. This can be handy.
Comment 38 Vitezslav Stejskal 2010-01-12 02:52:38 UTC
(In reply to comment #37)
> Of possible interest are behaviors in the presence of short lines. vim pads
> with spaces in some situations to keep/make a source/destination rectangular.

Yes, this is going to be a problem. I hope that with the new view hierarchy it will be possible to highlight areas behind the \n on a line.


> One complexity is TAB treatment.

Umm, this is going to be a problem. And another problem is going to be the use of proportional fonts. How does vim treats proportional fonts in respect to block select?


> Vim has a command, gv, to reselect the previous block acc'd to absolute
> coordinates. This can be handy.

How does this work exactly? Thanks
Comment 39 err 2010-01-12 09:35:42 UTC
(In reply to comment #38)
> > Of possible interest are behaviors in the presence of short lines. vim pads
> > with spaces in some situations to keep/make a source/destination rectangular.
> 
> Yes, this is going to be a problem. I hope that with the new view hierarchy it
> will be possible to highlight areas behind the \n on a line.

vim doesn't hightlight past the \n either; and the corners (first/last line, first/last chars) of the block must be within a line. But for example on a block yank (copy) intermediate short lines are lengthened so all lines are the same size. On a paste, where the destination is past a \n then it pads where needed so the copied text is still a rectangle.

> > One complexity is TAB treatment.
> 
> Umm, this is going to be a problem. And another problem is going to be the use
> of proportional fonts. How does vim treats proportional fonts in respect to
> block select?

AFAIK, vim does not support proportional fonts.

A simple approach to the corner cases is to detect them, for example tabs in the lines, and refuse to do the operation. Not nice, but better than jumbling text I guess.


> > Vim has a command, gv, to reselect the previous block acc'd to absolute
> > coordinates. This can be handy.
> 
> How does this work exactly?

Suppose block is (lines 3-5, cols 7-10). This is copied and pasted, then do some editing, then the "reselect previous block" command selects the (3-5,7-10). Actually, in vim the line numbers are text.Position so the line numbers may change if the document is modified before the first line and then number of lines may increase/decrease if edited between the first/last lines. The column numbers remain fixed no matter any changes. I haven't considered if these are the best semantics, but it seems to work out ok.
Comment 40 ardashev 2010-06-08 18:09:51 UTC
kdevelop is doing this for years.
Comment 41 tveimo 2010-06-20 08:02:44 UTC
The referenced plugin no longer works with netbeans 6.9, nor is the author maintaining it anymore, so I believe this issue has relevance.
Comment 42 benfyvie 2010-10-19 19:54:41 UTC
I would really like to see this too as the plugin that was used for a workaround no longer works in 6.9
Comment 43 Michel Graciano 2010-10-19 21:51:52 UTC
Created attachment 102501 [details]
Rectangular Tools for NetBeans 6.9

This attachment should work for 6.9.
Comment 44 Michel Graciano 2010-10-19 22:00:16 UTC
Jiri,
could you ask someone to include contrib/rectangularedittools module to nbms-and-javadocs build [1]? It would be a simple change at nbbuild/cluster.properties file adding this module to nb.cluster.experimental property if I am not wrong.

Thanks a lot
[1] http://deadlock.netbeans.org/hudson/job/nbms-and-javadoc
Comment 45 Jiri Kovalsky 2010-10-20 10:35:27 UTC
Good idea Michel! Robert Novak agreed to do modify the cluster but it will take some time. Thanks for your patience.
Comment 46 Michel Graciano 2010-10-20 11:19:50 UTC
I have just uploaded a version which works for 6.9 at plugins page [1]. I sttil need to sign the nbm to request the review but it should work anyway.

Regards
[1] http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=33497
Comment 47 ApeWare 2011-02-16 18:40:19 UTC
This thing has been on the board for almost 10 years and supposedly on dev track for at least last two. Rather than depending on a plugin, that (though we really appreciate the authors effort) has marginal functionality at best, can we get some kind of update on if/how development is going?
Comment 48 simonrees 2011-02-16 23:26:49 UTC
I would like to second ApeWare's request for information. I appreciate that development resources are limited, but the effort in at least managing our expectations is surely much lower. Thank you very much for an update.
Comment 49 Jiri Kovalsky 2011-02-17 10:27:43 UTC
Yes, there are still no resources available for implementing this feature in the Editor. Why don't you use Rectangular Edit Tools plugin [1] guys? It works quite nicely.

http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=33497
Comment 50 simonrees 2011-02-17 11:47:47 UTC
Many thanks for the status update (even though as you may guess it wasn't the answer I was hoping for !) To answer your question as to why I don't use the plugin... whilst I appreciate the effort that has gone into developing it, the lack of intuitive visual feedback irks me and if I really need to perform this type of editing I tend to prefer to switch to a different editor. (Please correct me if I am wrong and if the plugin now really visually highlights the selected block).
Comment 51 Michel Graciano 2011-02-17 11:51:36 UTC
(In reply to comment #50)
> Many thanks for the status update (even though as you may guess it wasn't the
> answer I was hoping for !) To answer your question as to why I don't use the
> plugin... whilst I appreciate the effort that has gone into developing it, the
> lack of intuitive visual feedback irks me and if I really need to perform this
> type of editing I tend to prefer to switch to a different editor. (Please
> correct me if I am wrong and if the plugin now really visually highlights the
> selected block).

You are right, AFAIK there is no visual highlight for it. Anyway, if anyone is up to try to implement it since the code is available. I can give any help if necessary, even to test and push it to contrib repository.
Comment 52 err 2011-02-17 17:38:52 UTC
(In reply to comment #50)

> lack of intuitive visual feedback irks me

FYI. jVi plugin has a fully functional visual block mode with a full set of operations (yank, put before/after, delete, replace-selection, insert before/after, replace-with-single-char) and any corner of the rectangular selection can be moved with the cursor. 

> and if I really need to perform this
> type of editing I tend to prefer to switch to a different editor.

If jVi is installed it can be enabled/disabled with a checkmark menu item under Tools (or the toggle action can be bound to a keystroke). 

I put together a minimal intro/how-to of visual block-mode for non-jVi users which is available at http://jvi.sourceforge.net/?javahelpset/jvi-vis_block.html (I don't know if there are any non-jVi users that take advantage of it)

jVi downloads from http://sourceforge.net/projects/jvi/files/jvi/
Comment 53 err 2011-02-17 17:44:36 UTC
(In reply to comment #52)

> FYI. jVi plugin has a fully functional visual block mode

Forgot to mention that tabs and tab-splitting are handled correctly.
Comment 54 Michel Graciano 2011-02-17 17:49:39 UTC
(In reply to comment #52)
It looks pretty amazing! I will test it and spread the word as soon as I get it to work.
Comment 55 tusharvjoshi 2011-02-18 02:33:41 UTC
Visual block mode in jVI plugin looks awesome.  This means we have some code for making rectangular selection already available in some other codebase.  

Can we get that part into the main stream so it becomes available to many non jVI users also?
Comment 56 err 2011-02-18 20:49:44 UTC
(In reply to comment #55)
> some code
> for making rectangular selection already available in some other codebase. 

The rectangular selection is displayed using stuff from org.netbeans.spi.editor.highlighting infrastructure.

In jVi's org.netbeans.modules.jvi.impl.NbTextView.java there is
    private static class VisualSelectHighlighter extends BlocksHighlighter

This does the highlighting based on an array of file offsets; the array elements are taken as pairs for start-highlight:end-highlight.
Comment 57 Miloslav Metelka 2011-08-30 12:59:30 UTC
Implemented in jet-main.
Toggle button for rectangular selection on/off is in editor toolbar (next to Toggle Highlight Search icon) or switch by Alt+Shift+R shortcut.
Please test the feature (once it proceeds into Dev build) and report possible improvements. Thanks.

http://hg.netbeans.org/jet-main/rev/503259537655
Comment 58 Michel Graciano 2011-08-30 13:10:35 UTC
Thanks Milo. I will take a look at this asap.
Comment 59 Quality Engineering 2011-09-01 14:20:11 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/503259537655
User: Miloslav Metelka <mmetelka@netbeans.org>
Log: #13857 - Cutting/Copying vertical blocks of text.
Comment 60 Miloslav Metelka 2011-09-01 16:29:26 UTC
New icons:
http://hg.netbeans.org/jet-main/rev/928899220fab

I'll improve the selection to retain the right coordinate when dragging mouse over empty line.
Also I'll add a border to the selection.
Comment 61 Miloslav Metelka 2011-09-06 15:52:31 UTC
Due to complaints that the rectangular selection "jumps" left and right when selecting over empty lines I've made a visual selection block bounded by a dashed line instead. See issue #201694.
Comment 62 Jesse Glick 2011-09-06 20:40:36 UTC
Refixing Version/Component.
Comment 63 Miloslav Metelka 2011-09-14 05:29:20 UTC
*** Bug 200027 has been marked as a duplicate of this bug. ***
Comment 64 stevenmz 2014-01-31 17:41:20 UTC
Vertical selection is an expected feature of any modern source editor and as such should be a *built-in* capability. Leaving it as a plug-in means that users downloading netbeans have additional work bringing the editor up to snuff so they can be most productive. I am not saying incorporate every plug-in into the main code line but surely this is an exception.
Comment 65 Jiri Prox 2014-01-31 19:57:26 UTC
the vertical selection is already part of IDE
Comment 66 kAlvaro 2014-01-31 20:17:26 UTC
Perhaps you were expecting the standard Alt+Drag trigger. The feature exists but it doesn't work that way.
See #209531
Comment 67 stevenmz 2014-01-31 20:22:26 UTC
Jiri / kAlvaro / anyone else

Can you document here how it is done? 

I do not see anything in the toolbar and alt+shift+r as mentioned in the comments above does not work (OS X).

Thanks for both of your quick replies earlier!
Comment 68 Jiri Prox 2014-02-05 10:11:36 UTC
 
> I do not see anything in the toolbar and alt+shift+r as mentioned in the
> comments above does not work (OS X).


The shortcut on mac is  Shift-Meta-R
ant it can be toggle from the editor toolbar - it is the 4th icon in the second group, just behind Highlight Search Result


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo