This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 111536

Summary: Indenting of pasted lines and parameters
Product: editor Reporter: darrinps <darrinps>
Component: Formatting & IndentationAssignee: Dusan Balek <dbalek>
Status: REOPENED ---    
Severity: blocker CC: gsporar, smig, ssteiner, wadechandler
Priority: P3    
Version: 6.x   
Hardware: PC   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description darrinps 2007-07-31 19:20:05 UTC
When pasting in a copied line the copied line should automatically line up with the line above it. 
The way it is now, the pasted line always seems to be indented too far to the right.  In eclipse for example, it
normally lines up as expected.

The same thing goes when adding a parameter.  When you shift over a parameter it should automatically line up underneath
the parameter above it.
Comment 1 Jiri Prox 2007-08-01 10:55:14 UTC
You can use smart-paste (ctrl-shift-v) to paste to the right position.
The rest is rather an enhancement than a bug

Comment 2 darrinps 2007-08-03 14:46:18 UTC
I opened a defect on the ctrl-shift-v suggestion you made as it does nothing (not even paste) in NB6M10 from the build
of the 27th of July.

I would still like to see the auto format take place like it does in Eclipse instead of needing to use the keystrokes
though if time permits.
Comment 3 _ wadechandler 2007-08-03 16:56:28 UTC
Yes, CTRL-SHIFT-V pastes for me, but it does not do anything different. It seems to work exactly the same as CTRL-V. I'm
not sure if I have tried this in the most recent dailies though, so next time I'm on my other system I'll try. It seems
though this would be something we would want to do on paste in any editor which has a formatter. Is there any reason why
paste would not be expected to put the pasted text into the format of the formatter associated with the given document?
Comment 4 Miloslav Metelka 2007-08-06 16:52:39 UTC
Well, a long ago there was a discussion about whether the default on ctrl-v should be formatted paste or regular paste
and the result was that the formatted paste should be on an extra shortcut. Feel free to raise a discussion about this
on nbui mailing list and I'll possibly revert it then.
Comment 5 swpalmer 2007-08-29 00:40:07 UTC
I think it makes more sense to have the regular ctrl-v paste "do the right thing", which would of course mean that it be
smart about what and where it is pasting and adjust the indent accordingly.   One of the goals of an IDE is to take care
of all these irritating little things for me in the first place.  It would be very rare for the automatic indent fix to
be the wrong thing to do when pasting in Java code.
Comment 6 _ wadechandler 2007-08-29 04:12:37 UTC
I agree with swpalmer, If there is a formatter and it will be used for a file type then I'm not sure when it would be
unwanted that the formatting matches the rest of the document. I guess if one opened a file and it was formatted
differently they wouldn't want to have the formatting match the rest of their file, but how often will this actually be?
I think it would be the minority use case.
Comment 7 darrinps 2007-10-12 15:16:07 UTC
What would be wrong with simply doing the same thing that Eclipse does?

In Eclipse, when you copy and paste, the newly pasted line is indented in relationship to the line above.

The way it is now in Netbeans, every time I copy and paste, I then have to go and manually add or remove spaces to get
the text to line up. 

In short, don't make the user use shortcut keys or anything manual at all...just do it like Eclipse (and other IDEs).
Comment 8 Vitezslav Stejskal 2008-02-29 07:48:19 UTC
*** Issue 128766 has been marked as a duplicate of this issue. ***
Comment 9 Vitezslav Stejskal 2008-02-29 07:48:35 UTC
*** Issue 56906 has been marked as a duplicate of this issue. ***
Comment 10 darrinps 2008-11-25 18:49:50 UTC
Any idea what version this might make it into?
Comment 11 _ wadechandler 2008-11-25 18:58:41 UTC

Does it work with CTRL+SHIFT+V? Was that resolved? If it does you can change your keymap in Tools|Options|Keymap to
switch the action around for the keystrokes. Obviously if CTRL+SHIFT+V doesn't work yet that won't be possible.
Comment 12 swpalmer 2010-09-23 23:34:14 UTC
I have used the CTRL-SHIFT-V rebound to CTRL-V workaround... and it is reasonable.. but if we want to go the extra mile, and match what the competition does... the past should also automatically add any missing imports for the pasted code (it is should know 100% which specific class needs importing if the code was copied or cut from another editor in the IDE)
Comment 13 smig 2013-12-01 00:21:14 UTC
*** Bug 186429 has been marked as a duplicate of this bug. ***
Comment 14 Martin Balin 2016-07-07 07:29:02 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss
Comment 15 yeswoman 2018-02-26 15:28:22 UTC
like darrinps, I also almost always have to manually indent when pasting blocks of code inside other code - that's very annoying.
Smart paste should be taking care of it, but it doesn't
[NetBeans IDE 8.2 (Build 201609300101)]