History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEA-18912
Type: New Feature New Feature
Status: Open Open
Assignee: Olesya Smirnova
Reporter: Matt Nathan
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
IDEA: Feedback

Auto format block after enter (like surround with)

Created: 30 Jul 08 17:46   Updated: 01 Aug 08 12:49
Component/s: Code Formatting and Code Style

Build: 7,757
Severity: Low


 Description  « Hide
I think it would be nice to have IDEA auto format a block of code after you close it with '}' or even insert the '}' for you.

For example if I had the code in a class:

public void method(int var) {
    System.out.println("Value = " + var);
}

and I wanted to change it to this:

public void method(int var) {
    if (var < 10) {
        System.out.println("Value = " + var);
    }
}

my sequence of thought would go (where | is the caret):

  1. public void method(int var) {
        if (var < 10) {|
        System.out.println("Value = " + var);
    }
  2. public void method(int var) {
        if (var < 10) {
        System.out.println("Value = " + var);|
    }
  3. public void method(int var) {
        if (var < 10) {
        System.out.println("Value = " + var);
        |
    }
  4. public void method(int var) {
        if (var < 10) {
        System.out.println("Value = " + var);
        }|
    }
  5. public void method(int var) {
        if (var < 10) {
            |System.out.println("Value = " + var);
        }
    }

What would be useful is at stage 2->3, when enter is typed, is to have the closing brace inserted by IDEA and the newly created block format itself (the caret is left after the inserted } at the end of the block).

I know this feature is available via the Surround With refactoring but I think doing it this way allows for a more flexible coding style.



 All   Comments   Work Log   Change History      Sort Order:
There are no comments yet on this issue.