New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to set a file association for files with no extension #57939
Comments
(Experimental duplicate detection) |
@rightaway does it not work when you set: {
"files.associations": {
"somefilename": "mydefaulttype"
}
} |
Yes, that works fine on the files named exactly |
still open? |
Is it not possible to have a special syntax instead of that "*" which actually matches every extensions? |
/[^.]+/ maybe allow regular expressions? Or how about reading the header, shell scripts often don't have an extension but they do have a header e.g. #!/bin/sh or #!/usr/bin/env bash |
According to VSCode Programming Languages Documentation the glob pattern should be supported, right? But I wonder why these don't work: "files.associations": {
"**/!(*.*)": "markdown",
"**/+([^.])": "markdown"
} You can test them on Digital Ocean | Glob Tool |
It's seems to not possible with glob only. Do you have suggestions on how to represent something without an extension, in Example - Add PCRE regex support, and specify the pattern type "files.associations": {
"**/page/*.js": "javascriptreact", // default: glob
".*/docs/[^\\.]*$": { "pattern": "regex", "language": "markdown" }, // pattern type specified?
} IMO this way is straightforward but looks not so good |
Since I also ran into this issue, I will provide my configuration for this. I wanted to have plaintext for all files without extension. So i just define all files as plaintext as default, and then overwrite specific languages with the correct setting. You can do this easily by opening a new file with an extension not yet in the list. It will be marked as plain text. Then click in the bottom status bar on "Plain Text" and "Configure File Association for ...." and select the language from the list. The user settings will be updated automatically and from this point onwards the file extension will be recognized correctly.
Hope this is helpful for someone :-) Cheers |
hey! how can i know the code for "mydefaulttype" - it's obvious for lots of stuff, but many times it's not. For example: "Git Commit Message" was shown in the status bar, but the code for it was "git-commit" which i found out after jumping various hoops. what would have been ur way to find out that code? |
I've had to resort to the suggestion of ThomasReulen above. A shame we have to dumb down vscode and will have to manually add a new entry each time we come to a language extension for the first time. (E.g. I just had to add Regarding #57939 (comment) one technique we've used to mix regex and plain filters like this is if it starts and ends in But can I suggest just adding no-extension as a special case? Ideas:
|
This changes the file association for absolutely all files. Should be possible to set a file association only for files that have no extension. So it would match
somefilename
but notsomefilename.txt
and not even.somefilename
.The text was updated successfully, but these errors were encountered: