How to ignore specific type of file in the reformat code action ?

Hello,

In fact I search to ignore twig (symfony 2) file when I reformat the code for the entire project.

If someone has a solution...

Thanks for advance

Michel

7 comments
Comment actions Permalink

Hi Michel,

Try this (not ideal, but should work for you):

  1. Settings | File Types
  2. Remove *.twig pattern (or whatever else you may have there) from "Twig" file type
  3. Add the same pattern to "Text files" type


The idea is -- Reformat Code does nothing for Text files.

0
Comment actions Permalink

Hello Andriy,

Thanks but with that I lost syntax highlighting and autocompletion but I would like to keep it.

0
Comment actions Permalink

Hi,

You have asked for a solution that would ignore those files "when I reformat the code for the entire project." How often do you do such reformat? Every time after making a change to some file?

You could add *.twig pattern to the excluded list, but that will be the same (even a bit worse)  -- those files will be excluded/hidden from project tree completely (at the end -- same effect).

There are no other options (that I'm aware of) that would allow you to dynamically (temporarily) exclude file from Code Reformat (when applied to a bunch of files/folders) unfortunately.

0
Comment actions Permalink

Here is a partial answer:

Create a scope[call it "Exclude Twig Files"
Set the scope to include your root source director and add a rule to exclude all files with an *.twig extension [Scope filter !*.twig]
From the project view, click on the drop down["Project"] and select your new scope
Now here is where I think there should be a command but cannot find it: expand all the subfolders
Second: select all the code files[somehow you have to exclude the directories though...]
CTR+SHF+L - reformat all selected files.

Second partial answer:
Run a "Find Usages", change it to use the "Exclude twig files" scope, search for some text you include in all your files[copywrite notice?]
Select all found files, CTR+SHF+L - reformat code

0
Comment actions Permalink

Hi, Community.

I'm running in same type of problem. I need to disable code style (reformat) for certain files. In my case I don't need to reformat files with such pattern: *.min.*

Workflow in our team is following: we have a File Watcher for SCSS files, that compiles compressed CSS files. Every chage is commited to Git with option "Reformat code before commit". And here we run in trouble, that our compressed CSS files become uncompressed again because of reformat. Solution to exclude *.min.* files from "File Types" will not work, because then we're not able to commit these files from phpStorm.

Also I don't want to change the workflow and force developers to reformat their files manually - one can easy forget this and then we can have fun resolving conflicts in merges.

Removing *.css file pattern form CSS file types sounds as dirty hack and will not work for us too, because we still need syntax highlight and reformat for CSS files, that are not compiled by SCSS.

Does anyobe have a solution for this? Or I should fire a feature request?

Regards.

0

Please sign in to leave a comment.