Creating a Surround in Quote Live Template in IntelliJ

Published by Rob on June 10th, 2008 - in IntelliJ, Java

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.

Related posts:

  1. Quote of the Day
  2. Migrating to FreeMarker
  3. A quick review of the IntelliJ GUI Editor
  4. Todays Cool Keyboard Shortcut In IntelliJ…
  5. Todays bit of IntelliJ coolness

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© Rob@Rojotek