IntelliJ Community . AutoNewline

 
AutoNewline 

HOME INDEX SEARCH CHANGES GO  

AutoNewline

Purpose

AutoNewline insert newlines and indent caret when open brace, close brace, semi-colon are pressed. Also, changes TAB to reindent.

Description

Special Note: This is experimental code. I have been using it for the past few days, but there are likely many bugs in the behavior, esp. in other people's environment. Has only been tested on Aurora 818 and 823.

AutoNewline enables electric behavior of the open brace, close brace, semi-colon characters. When these are pressed, the current line is reindented (if necessary) and then a newline is inserted and the caret is positioned on the next line at the indent level.

Exceptions: AutoNewline mode is only operational when editing a java file (PsiJavaFile?).

Exception: If you press open brace, close brace, semi-colon in a string literal, then they will just emit the character.

Cleanups: There are certain cases where the newline should not be emitted, e.g.

if (expression) {
    statement;
}
else (expression) {
}
In this case, a newline should not have been inserted between } and else. These cases are handled by cleanups. Here are the currently supported cleanups:

* brace-else-brace -- Cleanup } else { constructs by placing the entire construct on a single line. Clean-up occurs when the open brace after the else is typed.

* brace-elseif-brace -- Similar to the brace-else-brace clean-up, but this cleans up } else if (...) { constructs.

* brace-catch-brace -- Analogous to brace-elseif-brace, but cleans up } catch (...) { in C++ and Java mode. * defun-close-semi -- Clean up the terminating semi-colon on top-level function or class definitions when they follow a close brace. Clean up occurs when the semi-colon is typed.

Please refer to the CCMode AutoNewline minor mode documentation for more background on this feature. http://cc-mode.sourceforge.net/cc-mode.html#Auto-newline%20Insertion

How to deploy.

NOTE: You must have Editor->Smark Keys->Enter->Smart Indent turned on for AutoNewline to work.

Relevant posts/requests:

Feature Request #12358- SmartKey? semicolon ; http://www.intellij.net/forums/thread.jsp?forum=15&thread=30002

Feature Request #12357- SmartKey? Brace opening { and closing brace } http://www.intellij.net/forums/thread.jsp?forum=15&thread=30000

Key Mapping.

AutoNewline plugin modifies the behavior of the open brace (shift [), close brace (shift ]), semi-colon (;), and TAB keys.

You will find the keymappings under Other->AutoNewline You can selectively disable each feature. For the TAB key, it is bound to AutoNewline.IndentLinesAndCaret by default. If you don't want the caret to be repositioned, you can bind it to AutoNewline.IndentLines.

History.

0.3 - Jun 13, 2003

Initial Version.

-- AlexL - Jun 13, 2003

IntelliJPluginWebForm
IntelliJPluginName: AutoNewline
IntelliJPluginVersion:
IntelliJPluginVendor:
IntelliJPluginBinary:
IntelliJPluginSource:
IntelliJPluginClassification: CodeHelper?
TopicClassification: IntelliJPluginPackage
TopicShortDescription: AutoNewline insert newlines and indent caret when open brace, close brace, semi-colon are pressed. TAB reindents line.
TestedOnOS: AnyOS
ShouldRunOnOS: AnyOS

Attachment: sort Action: Size: Date: Who: Comment:
AutoNewline-0.3.jar action 23555 14 Jun 2003 - 00:27 AlexL  

e d i t a t t a c h r e f - b y d i f f s m o r e
Have ideas, requests, problems regarding this site? Send feedback.
Copyright © 2000-2003 by the contributing authors. All materials at intellij.org are the property of the contributing authors.