Home > Java, NetBeans > NetBeans – Reformat text

NetBeans – Reformat text

The NetBeans IDE has a great shortcut for reformatting sourcecode.  Simply hit ⌃⇧F (ctrl shift f), and all the sourcecode in the current file will be reformatted.  This is a great feature, and I only stumbled upon it through a StackOverflow search.

Before reformatting. This is how the code looked on StackOverflow

After running the algorithm. Note how much more readable it is

(Sourcecode taken from this stackoverflow post)

The other time it’s useful is when working on a project where someone is using very large tab settings (e.g. 8 spaces per tab instead of 4).  This can make it very difficult to read.  By invoking this command, you’ll put the code into a much more readable format.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: