How to NOT replace tabs with space characters before // comments?

I like to separate trailing line comments in Java with Tab characters. However, when IntelliJ reformats code, it insistes on using spaces here. How can I make it leave my tabs alone here?

This is essentially the same problem as brought up here:

   http://stackoverflow.com/questions/12033941/intellij-idea-11-1-3-replaces-tabs-with-space-characters-before-comments

It seems odd I can't make IntellyJ respect my desire to use tabs here, or at least leave them as tabs if that's what I typed.

Mike

4 comments
Comment actions Permalink

Unfortunately it is not possible. You could try to commit file with comment indented by tab and after that use "reformat only vcs chaged text" which will modify text changed since last commit only, therefore you comment's tab will be preserved.

0
Comment actions Permalink

While your suggestion helps somewhat with commits, there are other circumstances where automatic formatting is done, such as when pasting code or when adding brace levels in the code, which causes the code inside the braces to be reformatted.

I find it odd that I can't make the editor leave my code as-is in this respect, and also that the editor has such a preference for using spaces over tabs. Both are certainly valid and common forms of white-space in code, so I really see no reason for the IDE to unnecessarily replace one for the other in this context. Why not just leave those tabs alone here?

I can understand why the IDE has an opinion about white-space at the beginning of a line, since those control indentation. But trailing comments shouldn't really be of any concern to the editor. If it really needs to mess with white-space here, please add a user preference for what to do (i.e., "use spaces", "use tabs", "leave as-is").

Mike

0
Comment actions Permalink

Looks like a valid request, thanks for an explanation, Mike. Please fill an issue to https://youtrack.jetbrains.com/issues/IDEA

0
Comment actions Permalink

Done.

Thanks for taking the time to answer, making sure I just hadn't misunderstood one of the myriad of space settings.

Mike

0

Please sign in to leave a comment.