Is there a shortcut for wrapping a statement with system.out.println in IntelliJ

In Intellij Idea 13.1, there is a shortcut way called "postfix code completion".

So, to wrap an expression, object or variable with System.out.println, you simply write its name, put a dot then write sout, then hit tab. So, for example:

new MyObject().sout + <tab>  

will be converted to

System.out.println(new MyObject())

More examples:

"Hello World!".sout

int myVariable = 5;
myVariable.sout

You can get more information about postfix completions on this page: http://blog.jetbrains.com/idea/2014/03/postfix-completion/


You can it with defining a Live Template (configurable in Settings->Live Templates->Surround). Look for an example of Surround with {} there.

After that you'll be able to select the variable (probably Ctrl+W), then choosing your template (Alt+T) - keyboard only.