Bug 186429 - Autoindent on paste
Autoindent on paste
Status: RESOLVED DUPLICATE of bug 111536
Product: java
Classification: Unclassified
Component: Editor
6.x
PC Windows 7 x64
: P3 with 1 vote (vote)
: TBD
Assigned To: Dusan Balek
issues@java
: USABILITY
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-05-20 12:03 UTC by ssteiner
Modified: 2013-12-01 00:21 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ssteiner 2010-05-20 12:03:21 UTC
I'd like Netbeans to automatically ident a copied and pasted piece of code in function of where it is being pasted.

Take this method

public void test(byte value)
    {
        Object value = getValue(value);
        if (value != null)
        {
            // do something here, then return
        }
        else
        {
            // do some preparation
            value = getValue(value);
        }
    }

Now after the line

value = getValue(value);

you need to run another check on value... so you copy the following piece of code

if (value != null)
        {
            // do something here, then return
        }

and you paste it to the line after

value = getValue(value);

The result looks like this:

public void test(byte value)
    {
        Object value = getValue(value);
        if (value != null)
        {
            // do something here, then return
        }
        else
        {
            // do some preparation
            value = getValue(value);
            if (value != null)
        {
            // do something here, then return
        }
        }
    }

And it should look like

public void test(byte value)
    {
        Object value = getValue(value);
        if (value != null)
        {
            // do something here, then return
        }
        else
        {
            // do some preparation
            value = getValue(value);
            if (value != null)
            {
                // do something here, then return
            }
        }
    }

Other IDEs (e.g. Visual Studio) automatically adapt the identation so that the entire bit of code matches up (so in order to do this, upon pasting, the "uppermost" bit of code should line up with the the default identation of the line where the code is being pasted. In the example, the pasted if is idented by two levels.. and the line where it is being pasted is idented by three levels.. meaning the whole bit of code needs an additional level of identation to line up.
Comment 1 smig 2013-12-01 00:21:14 UTC

*** This bug has been marked as a duplicate of bug 111536 ***


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