Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a template (sleep) in Eclipse 4.2.1 that should expand to

try { Thread.sleep(1000); } catch (Exception e) {}

I want Eclipse to add it as one line, just as I put it in the template. However, Eclipse autoformats it after inserting to:

try {
} catch (Exception e) {

I have tried @formatter:off, but that does not work. I have code cleanup switched off.

Is there any way to disable formatting for all templates, since the only templates I use are one-liners anyway?

share|improve this question

Window > Preferences > Java > Editor > Templates, as you know.

There is the list of templates, defaults given by Eclipse, and yours.

At the bottom of the dialog, in Eclipse Juno (4.2), I see a checkbox Use code formatter. Unchecking it deactivates the auto-format at insertion time.

Alas, it is a global setting, applied to all template... But well, that's what you look for, anyway.

[EDIT] I see the same checkbox in Indigo (3.7).

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .