SmarterEditor

 editor window

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.
Image demonstrating a selection workflow with SmarterEditor

With SmarterEditor: selecting and removing an if statement takes 3 key presses

Image demonstrating a selection workflow with SmarterEditor

Without SmarterEditor you have to press more than 8 keys (7x Ctrl+W + 1x Backspace + move back the caret)

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.
Image demonstrating a formatting workflow with SmarterEditor

With SmarterEditor: reformatting an if statement takes 3 key presses

Image demonstrating a formatting workflow without SmarterEditor

Without SmarterEditor you have to press 7 keys (6x Ctrl+W + 1x Ctrl+Alt+L)

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
SmarterEditor split string
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.
SmarterEditor smart beginning of block navigation
  • 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.
SmarterEditor smart end of block navigation
  • 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.
SmarterEditor smart block selection in Java
  • Working on XML tag body: Copy all siblings and the parent tag by calling this action twice and then ctrl + c
SmarterEditor smart block selection in XML
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.
SmarterEditor smart format of a Java method


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.
SmarterEditor smart reordering of selected lines