PhpStorm header.php file is greyed out - ide

I'm using PhpStorm and for some reason in all of my projects the header.php file got messed up. It's just greyed out and PhpStorm doesn't recognize the PHP in the specific files named header.php. The rest is working fine.
It's driving me crazy and I can't figure it out. I already checked file templates, reset it to default. Nothing helps.
I would appreciate any solution, thanks.

Go to Settings/Preferences | Editor | File Types
Locate Text entry in top table
Locate and remove header.php (or very similar one) pattern from bottom table and remove it.
Right now you have somehow told IDE to treat such file as Plain text and it does it for all files named header.php regardless of their location (quite likely it happened when you were creating new header file and forgot to enter .php part).

Related

WebStorm not showing .vue syntax highlighting on on file but is on another

Does anyone know what is causing this problem? I can't seem to figure it out.
When I create a new .vue file, I can't get any autocomplete/syntax highlight at all.
But the one I created at the start of the project seems to work fine.
Looks as if the file GameDetails.vue is treated as plain text file. Does the issue persist if you rename the file? Please check the registered patterns in Settings | Editor | File types, Text and Auto-detect file type by content file types - can you see GameDetails.vue or any pattern with .vue suffix there? Removing it from the list should solve the problem.

File named "auth_actions.dart" won't be highlighted in Intellij-idea

I created a file named "auth_actions.dart" in a dart project(either angular or not). The file content would have text colour being plain white, without any highlighted.
If I rename it to "auth_action.dart" or "auth_actionss.dart", the highlight will come back.
I did some experiments even from some random projects downloaded from github, all of them had this issue.
Anyone know how to fix it? Does anyone see the same issue using the name "auth_actions.dart"?
I assume you accidentally added the file to
Preferences > Editor > File Types > Recognized File Types > Text
Remove it from Registered Patterns to get hightlighting again.
You could accidentally mark it as plain text (the option is in the right-click menu). In this case, the option to mark it back as a Dart file is also in the context menu.

Intellij failed to detect file type

I have intellij 13.1.3 Ultimate and have been using it for my PHP projects. All my files.php are nicely hightlighted for php.
This morning I had to create a new file called "report.php". At first I create it with right click > new > file, but this gave me no hightlighting. So I deleted it and tried again with a right click > new > php file with same result. Now what ever the way I create it, it thinks the file is txt (it seems so) and there is no code highlighting. It's pretty frustrating.
I have tested the creation of a new file with a different name "reports.php" but this time with right click> new > PHP file, and it came nicely highlighted. i tried to rename the file to "report.php" but it came back to no highlighting!!
It seems Intellij is stuck with the name report.php being a type text.
I tried to delete the file, restart the IDEA, recreate it the right way, no luck.
I tried power save mode on, and off. No luck.
I tried File > invalidate cache/restart, ... no luck.
I'm out of options here...
Is there a way to FORCE intellij to interpret a file? Is the name "report" a reserved word?!?!?
How can it be so stupid...
edit: I also tried the suggestion in : IntelliJ: how to force editor to treat a file as javascript? but php is not in the list of the Template data language
Also in settings > file types, I saw two Php file entries. One with no extention, and one properly configured. I deleted the bad one but it reappears after a restart of the IDEA!
Please go to Settings | Editor | File Types and remove the association of "report.php" with the text file type. (The erroneous association was created because of a bug in IntelliJ IDEA, but unfortunately we don't currently have specific steps to reproduce for it.)

Webstorm not recognising JavaScript file

Webstorm doesn't recognize one of my .js files as a JavaScript file so I'm losing syntax highlighting and being able to add break points. I've looked in the workspace.xml file and the file in question seems to have similar settings to other .js files that work correctly.
If I change the name of the file it works ok. So somehow Webstorm is stuck on misinterpreting the type of a file that has this name. Where else can I edit the project?
So I see three possible reasons for the problem:
The file was marked as 'Plain text'
There is a pattern for 'Text files' file type that matches this file (or back: file type 'JavaScript' exclude this file name). See image below
There is a custom plugin that overrides default behavior for files with this name (unlikely)
Updated: after several years I've found one more reason for the behavior and most likely it the main source of the issues. When you create a file without any extensions the "Register New File Type Association" is appeared. And you can accidentally specify a new file type, for some file name. It is can be fixed with (2) but it is the reason why the pattern was added there.
Note: the solution works for all IDEA-based IDEs: IntelliJ IDEA, WebStorm, RubyMine, PyCharm, PhpStorm.
File -> Settings -> Editor -> FileTypes -> Text files -> check for "ContentRepository.js" pattern there and remove it.
If the file was marked as "Plain Text", then this can be fixed as follows:
Right click on the file.
One of the menu options is "Mark as Javascript" . Just below "Delete".
Click that. Your file is now recognized as javascript by WebStorm.
Since WebStorm was not allowing screenshots after right click so couldn't add it here.
My problem was with Auto-detect file type by context
For me this did the trick
1) Preferences
2) Editor
3) FileTypes
4) Search for javascript
5) Add *.js to registered patterns
You can also try "Template data languages" (in file > settings) which will force a specific language synatax high-lighting on a specific file or folder. See screenshot below
For a block of code you can also use "language injection". Simply high-light the block of code, wait for the little lamp to appear then select the bottom choice and then the language you need (screenshot also attached)
In case it is helpful elsewhere (OMG this was scary).
For some reason IntelliJ was not recognizing any .js file in my project (even after .idea removal (rm -rf .idea)).
I went to Webstorm (in my case RubyMine): Webstorm > Preferences ... > Editor > File Types then went to Recognized Filed Types, picked Javascript (but whatever file type you are missing will do), then added back a Registered Patterns entry of *.js
Of course, press Apply and then Ok.
Wow, scary stuff. but solved my problem, hope it does for someone else.
I was always trying to add .js as a recognised file types, but somehow .js was added to Ignored Files and Folders.
I just removed .js from Ignored Files and Folders and it worked for me.
Preferences
Editor
FileTypes
Ignored Files and Folders
Remove *.js
2022 update!
Right click on file and choose JavaScript

How to remove BOM in Intellij Idea

I'd like to remove Bite Order Masks from my
UTF-8 files in Intellij IDEA, how can I do this?
The problem is that if I'm trying to do it via other editors (e.g. Akelpad),
when I modify the file later in IDEA it somehow remembers that BOM
was present and adds it to my file again (((
Tested on PHPStorm 8:
Right click on a file in the project tree,
click on "Remove BOM"
(Not sure if it exists on the base platform, comments will be helpful)
There is no such action to remove BOM from UTF-8 files in IntelliJ IDEA. There was a bug that BOM is removed, but it was fixed a long time ago.
When you remove BOM externally, make sure the file is synchronized with editor, try File | Synchronize.
If IntelliJ IDEA still thinks that this file has BOM, please file an issue with the steps to reproduce.
Intellij Idea has an option, File->Remove Bom, but it looks doesn't work very well, I got "This file has mandatory Bom" error
The following tips work for me
1) create new empty file (for example: temp123.java)
2) make sure that code-page/encoding for that file is UTF-8
3) copy whole content from original to newly created file (select all, copy, go > to another tab, paste) and save
I referenced link below, can be combined with Intellij Idea File->File Encoding-> Reload/Convert to UTF-8
IDEs Support: Remove BOM from file - how ?
I had the same Problem.
I found this issue and a "works for me"-fix:
http://youtrack.jetbrains.com/issue/IDEA-86880#comment=27-386505
Hope it helps