Open rightaway opened 5 years ago
(Experimental duplicate detection) Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:
@rightaway does it not work when you set:
{
"files.associations": {
"somefilename": "mydefaulttype"
}
}
Yes, that works fine on the files named exactly somefilename
. But can't figure out any way to set a default file type for files with no extension to work.
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 inclusive glob only.
Do you have suggestions on how to represent something without an extension, in settings.json
?
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 .
"files.associations": {
"**/*": "plaintext",
"*.go": "go",
"*.{htm,html}": "html",
"*.{js,ts}": "javascript",
"*.py": "python",
"*.sh": "sh",
"*.json": "json",
"*.md": "markdown",
"*.ps1": "powershell"
},
Hope this is helpful for someone :-) Cheers
"somefilename": "mydefaulttype"
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 "*.jsonl":"jsonl"
)
Regarding https://github.com/microsoft/vscode/issues/57939#issuecomment-1033993749 one technique we've used to mix regex and plain filters like this is if it starts and ends in /
then treat it as a regex; though not ideal here because it still looks glob-ish.
But can I suggest just adding no-extension as a special case? Ideas:
Item
to be blank, and have that mean no extension_
it means no extension.files.noExtAssociation
as a new setting.Why does !(*.*)
not work here?
I use the VSCode extension JatinSanghvi.color-my-text
and that glob pattern works there to get only files with no extension.
I don't know why, but !(**/*.*)
, !(*.*)
, and many variants I've tried just not work
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
.