Introduction
SmarterEditor was made to speed up your work in the code editor. It adds shortcuts and actions to perform consecutive actions at once.
- Selecting code
- You are working in a Java file and would like to remove the current if statement. If you do this manually you have to either use the mouse to select the text and then press backspace to remove it. Or you position the caret into the block, press Ctrl+W several times and then backspace to remove it. Or you move around with the arrow keys to select it and then remove it with backspace.
- Formatting code
- Formatting just a certain range in your editor is not straight forward in IntelliJ. You first have to select it (by mouse, by repeatedly pressing Ctrl+W or by using the arrow keys) and then you reformat with Ctrl+L. SmarterEditor replaces all this with a single keypress.
SmarterEditor works with several languages. At the moment the following languages are supported:
- Java
- JavaScript
- CSS
- XML
- Bash (with the BashSupport plugin)
- SQL
- PHP
Concepts
SmarterEditor works with several languages The basic concept is a navigation context. This is a certain portion of text in your file which corresponds to a statement/expression/element of the language you’re working in.
- Block statements
- If, Switch, Loops. If Java it maps to If, Switch, While, For, Do-While, etc. In other languages it maps to similar elements.
- Method and function definitions
- In Java, it’s mapped to methods, in Bash to functions, and so on.
- Class definitions
- In Java, it maps to a class, etc.
- HTML and XML tags
- This is only available in the matching files, of course.
Features
- Split the current string literal at caret or around selection
- Press
Alt +
PLUS
(Edit → Smart split. This action splits a string into two parts and positions the caret between two parts. For example: the string
"abcd"
is turned into"a" + "bc" + "d"
if"bc"
was selected.
Examples:- Working on Java code: simply split a string into two parts and enter a variable in between
- Jump to the start of a navigation block
- Press
Ctrl +
Alt +
HOME
(Edit → Smart home). This action moves the editor caret to the beginning of the next parent navigation context.
Examples:- Working on a Java loop statement: Use this action to jump to the loop beginning.
- Working on XML tag body: Use this action to directly jump to the opening tag. Press again to jump to the parent tag definition.
- Jump to the end of a navigation block
- Press
Ctrl +
Alt +
END
(Edit → Smart end). This action moves the editor caret to the end of the next parent navigation context.
Useful for:- Working on a Java loop in a method: Use once to add code after the loop, press another time to move after the method to add more class level code.
- Working on XML tag body: Press to add another tag after the current one. Press again to move after the parent tag.
- Select a navigation block:
- Press
Ctrl +
Alt +
Shift +
D
(Edit → Select favourite). This action select the next parent navigation context. It can be called multiple times to select the next parent context. Before you needed to press
Ctrl +
W
multiple times, which works on a much finer grained model.
Examples:- Working on a Java code: Select code on a more coarse grained model, e.g. anonymous class, then the method, then the inner class, then the outer class.
- Working on XML tag body: Copy all siblings and the parent tag by calling this action twice and then ctrl + c
- Format a navigation block
- Press Ctrl + Alt + Shift + F (Edit → Format favourite). This action formats the next parent navigation context according to the code style settings. It puts a selection on the reformatted text. It can be called multiple times to reformat the next parent context. Before you needed to press Ctrl + W multiple times, then Ctrl + Alt + L and confirm the message box.
Examples:
- Working on a Java method: If you want to reduce whitespace changes just reformat the current method by calling this action.
- Working on XML tag body: Reformat the current tag and child context by calling this from anywhere on the first level below the tag.
- Sort selected lines
- Invoke Edit → Sort selected lines. This action reorders all selected lines in alphabetical order.