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

Related searches

It appears to me that sometimes I want to print the values of a variable, so I repeat the following actions:

  1. write sout TAB (shortcut for system.out.println)
  2. write the variable name inside the function

Is it possible in IntelliJ to wrap a variable with a function, using keyboard shortcuts only?

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;

You can get more information about postfix completions on this page:

Is there a shortcut for wrapping a statement with system.out.println in , write sout TAB (shortcut for system.out.println); write the variable name inside the function. Is it possible in IntelliJ to wrap a variable with a function, using� System.out.println(""); That's nice but what I want is to be able to select a word and then have this appear below the line in which the word is found: System.out.println("word: " + word); Yes, this is exactly what the keyboard shortcut of the week (see yesterday's blog entry) does for System.err.println.

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.

Code Formatting – IntelliJ IDEA Blog, System.out.println("I have no idea where the indentation is supposed to be"); system shortcuts on certain versions of Linux), to format just the if statements should always have curly braces, we go into Wrapping and Braces� IntelliJ IDEA keyboard shortcuts. IntelliJ IDEA has keyboard shortcuts for most of its commands related to editing, navigation, refactoring, debugging, and other tasks. Memorizing these hotkeys can help you stay more productive by keeping your hands on the keyboard. Use a keyboard with the English layout.


yourVarOrSmthng . sout + Tab

Works in IntelliJ 2019.1.1

Tips for Writing Code in IntelliJ IDEA – IntelliJ IDEA Blog, This screencast shows how the features and shortcuts of IntelliJ IDEA help us to sometimes we work from the outside in – we write code the way we want to to suggest the best way to complete this statement given the return type. we can change the settings for Chained method calls to “Wrap always”. 46 Is there a shortcut for wrapping a statement with system.out.println in IntelliJ Oct 19 '14. 41 Spring Security redirect to previous page after successful login

Live templates - Help, To expand a code snippet, type the corresponding template abbreviation postfix completion and wrap the expression with an if statement. So I want to have a popup to ask me what I want to to wrap it with and I'll be able to enter System.out.println("<text to wrap>"); I can do this by vertical typing but would be quicker if I had a template for that.

Code completion - Help, When you invoke code completion, IntelliJ IDEA analyses the context and suggests the choices that are reachable from the The initial expression gets wrapped with an if statement: You can use the following live templates shortcuts for one of the most frequently used statements: sout : prints System.out. It doesn't have a shortcut by default, but you can assign one in the keymap. AndroidStudio >= 1.4.1: the options are under File > Settings > Editor > General - under the Soft Wraps sub-group. You can also right click the gutter (the vertical bar where line number is shown) and select "Use Soft wraps" - thanks to Bajal for comment.

IntelliJ provides us with this configuration through templates. To do that you can go to Preferences > Editor > Live Templates choose output and click on + button and input the following configuration: Abbreviation: sout8; Description: Prints in Java 8; Template text: System.out::println; Applicable in: Java: statement, expression; Click on

  • This would only make sense if you had the variable on a line by itself. Better to run the code in a dubugger and look at its value in a watch window.
  • Thanks! searching a bit more on live templates, I found out that the shortcut soutv might be useful for printing variables