Product Development in Brisbane

Creating a Surround in Quote Live Template in IntelliJ

One of the features I like about TextMate is the smart insertion of characters, like when I’m typing text, highlight a word, and type ", TextMate will wrap the word in quotes. Unfortunately IntelliJ doesn’t have this behaviour by default, and makes surrounding some text in quotes messier than what would be preferred.

It is possible to make this task much easier, through the use of live templates. Here is how to do it.

  1. navigate to the add a live template screen via the following path: settings – live templates – add
  2. type "$SELECTION$" as the template text, ensure that the context is suitably broad, give it a meaningful name, and you are done. This can be seen in pictures.

IntelliJ setingslive templatesadd template screen

You will now be able to access the template using the cmd-option (ctrl-alt) t "surround with" shortcut, making it easy to wrap text (code) in quotes using IntelliJ.

Leave a Reply