HOW-TO: Surround text with quote in IntelliJ
A quick tip on how to surround a selection with quote or brace in IntelliJ.
If you wish to be able to easily surround a selected text with quote or brace you have 2 options I know about. You can create a Live Template in surround
group and then call it with either Ctrl+Alt+t
or Ctrl+Alt+j
or you can configure Smart Keys
properly to achieve it.
You can find this option in IDE Settings > Editor > Smart Keys > Surround selection on typing quote or brace
. When this option is selected and you type quote (single or double) or brace (curly, square, parentheses , angle) whilst the text is selected, it will be automatically surrounded with either quote or brace. Pretty handy.
Enjoy!
Thanks ! That was the thing i was looking for ! ;)
ReplyDeleteIs it possible to add to the list of characters that trigger this behavior? Now, typing e.g. '*' with some text selected simply overwrites it even with this option checked...
ReplyDeleteTIA
This was mostly helpful, but slightly different on a Mac.
ReplyDeleteFWIW with IntelliJ IDEA 2016 on Mac OSX, you configure Smart Keys thusly:
Menu bar:
IntelliJ IDEA
› Preferences...
› Editor
› General
› Smart Keys:
Check: "Surround selection on typing quote or brace".
Thanks :)
ReplyDeleteCool
ReplyDeletevery nice!! thanks Gerald for the mac option
ReplyDeletevery nice!! thanks Gerald for the mac option
ReplyDeletenice
ReplyDeletenice, that is exactly what i want
ReplyDeletethanks , that is exactly what i want !!
ReplyDeleteCode Leaked! That worked. Thanks for saving my life!
ReplyDeleteworks excelent !! select and press quote :D
ReplyDeleteThanks @RAFAŁ
ReplyDeleteThanks :)
ReplyDeleteThank you^^
ReplyDelete