At work there are a lot of file without extension. They are all COBOL files, so now I manually change their associating to COBOL each time I open one. But I was looking for a way to make VS Code treat files without extension as COBOL automatically.
I know you can add file associations in the settings, but the only thing that works is to add "*": "COBOL"
there, but then everything is considered a COBOL file... I also tried `"[^.]": "COBOL" hoping regex would work but it didn't.
Is there a way to do this?
You can apply the file associations to all files in a given directory only:
"files.associations": {
"**/RootDir/**/*": "COBOL"
}
This way, all files in /RootDir/
, or one of it's sub-directories, will be mapped to COBOL.
All files outside of /RootDir/
will still be mapped as usual according to their extensions.
Suppose your /RootDir/
doesn't contain only COBOL-files, but also some other file types. In this case you can go further and define exceptions for the file associations:
"files.associations": {
"**/RootDir/**/*.bat": "bat",
"**/RootDir/**/*.sh": "shellscript",
"**/RootDir/**/*": "COBOL"
}
Basically you're instructing Visual Studio Code to map all files in /RootDir/
to COBOL, except for .bat
and .sh
which are mapped as Batch and Shellscript, respectively.
As above, all files outside of /RootDir/
will still be mapped as usual according to their extensions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With