Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse Formatting Try/Catch Blocks with Braces on Separate Lines

Tags:

eclipse

I'm trying to set up Eclipse so that it formats a try catch finally block (when pressing CTRL+SHIFT+F as follows:

try
{
    // some code
}
catch (IOException exception)
{
    // some exception handling code
}
finally
{
   // some more code
}

I found the formatting options under Window >> Preferences >> Java >> Code Style >> Formatter and added a new Active profile, however I can't see an option for try catch blocks on the braces tab. I've set everything on that tab to "Next line", however the code now formats as:

try
{
    // some code
} catch (IOException exception)
{
   // some exception handling code  
} finally
{
   // some more code
}
like image 803
magritte Avatar asked Oct 20 '25 01:10

magritte


1 Answers

The settings you need are in the Control Statements tab:

  • Insert a new line before 'catch' in a 'try' statement
  • Insert a new line before 'finally' in a 'try' statement
like image 198
mavroprovato Avatar answered Oct 23 '25 07:10

mavroprovato