It appears to me that sometimes I want to print the values of a variable, so I repeat the following actions:
Is it possible in IntelliJ to wrap a variable with a function, using keyboard shortcuts only?
In IDEA, you can type sout and press Tab to generate System. out. println automatically.
In Eclipse, you press CTRL + SHIFT + O “Organize Imports” to import packages automatically. For IntelliJ IDEA, if you press CTRL + ALT + O “Optimize Imports”, it just removes some unused imports, never imports any package.
You can enable soft wrap for the editor with ⇧⇧ (macOS), or *Shift+Shift (Windows/Linux), for the Search Everywhere dialogue, and then typing in soft wrap. You can also go to Preferences/Settings > Editor > General to enable Soft Wraps for more file types by default.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With