Spaces within lines and re-formatting of code

Hi,

I have constants defined in some source files, like this:

 
NSUInteger const kMyFirstConstant = 100;
NSUInteger const kMySecondConstant = 200;
NSUInteger const kMyVeryLongNamedConstant = 300;


Just for readability's sake, I align the '='s signs, like so:

NSUInteger const kMyFirstConstant         = 100;
NSUInteger const kMySecondConstant        = 200;
NSUInteger const kMyVeryLongNamedConstant = 300;


However, if I reformat the source file, all of these spaces get stripped out again.


Is there any option available in the Code Style -> Spaces tab of the preferences which will tell the re-formatter to leave these spaces in?  I can't see one, but someone hopefully can tell me if anything like this is available.


Cheers,
Corey.
2 comments
Comment actions Permalink

Hi Corey.

Please go to Preferences | Editor | Code Style | C/C++/Objective-C | Wrapping and Braces | Variable groups - enable 'Align in columns'

0
Comment actions Permalink

While I appreciate the group alignment feature, there are some things which I align in my code which I wouldn't expect IntelliJ to do for me, which is fine but I don't want IntelliJ to remove my formatting.  Is there a simple option "Don't remove extra spaces within a line"?  Here is an example:

if (r.getAccountID()     != null) { rec.put("account",      r.getAccountID());     }
if (r.getGroupID() != null) { rec.put("group", r.getGroupID()); }
if (r.getIngestPointID() != null) { rec.put("ingest_point", r.getIngestPointID()); }
if (r.getRegionCode() != null) { rec.put("region_code", r.getRegionCode()); }

 

0

Please sign in to leave a comment.