Overriding indent and whitespace settings per file or folder

Source files I write for my project use consistent formatting, such as 3 space indents, no trailing whitespace, newline at end of file, etc. Occasionally, third-party scripts/source code is viewed and/or tweaked, but those files might not use the same formatting standards (such as tab indents, lots of trailing whitespace, and no newline at end of file).

Is there any way to disable formatting on a per file or per folder basis? Perhaps something like the "// ReSharper disable All", but for formatting instead of warnings?

Currently, making small changes to a third-party file might trigger lots of other edits when the file is saved, such as removing trailing whitespace throughout the file or adding a newline at the end, and there doesn't seem to be an easy way to indent with tabs in just that file when the project is set to space indents.

I'm primarily interested in disabling formatting or overriding settings for the following in specific files or any files under specific folders, while retaining the current project settings for all other source files:

  • Indents (tabs instead of spaces)
  • Trailing whitespace (ignore it and don't remove)
  • EOF newline (don't add one)
0
1 comment

Hi Michael Ryan,

 

To disable formatting on a per-file basis, please enable the formatting engine markers and place an appropriate marker at the top of the file you want to ignore:

  1. Tick the "Enable formatter markers in the comments" checkbox under Settings | Editor | Code Style in the Formatter Control tab
  2. Alter the control comments (Formatter off/on) if you want
  3. Place a Formatter off comment at the top of the file you want to ignore. For example, the default comment should look like this:
// @formatter:off

Let me know if it helps.

0

Please sign in to leave a comment.