I want all new files in VS Code to open as .sas files. (Solution at bottom)
Attempt 1
- Open a
.sasfile in VS Code. - ctrl + , to open settings UI.
- Search for
files, then clickFiles (19)in the left menu. - Insert
sasor${activeEditorLanguage}into "Files: Default Language" box. - Close the settings window.
- Press ctrl + n to open a new file.
- Bang head on desk since the new file is still a
.txtfile instead of.sas
Attempt 2
Open a
.sasfile in VS Code.ctrl + , to open settings UI.
Search
workbench.settingsChange Settings: Editor to
jsonClose the editor
ctrl + , to open settings file in JSON.
Become surprized because I see so few settings to modify (I would have expected more settings in this file):
{ "editor.insertSpaces": false, "editor.wordWrap": "on", "workbench.settings.editor": "json" }Add lines to the file to try to dictate that new files should open with
sassyntax highlighting and with the.sasextension, save and close:{ "editor.insertSpaces": false, "editor.wordWrap": "on", "workbench.settings.editor": "json", "files.associations": { "*.sas": "sas" }, "files.defaultLanguage": "SAS" }Press ctrl + n to open a new file.
Bang head on desk since the new file is still a
.txtfile instead of.sas
When using ctrl + , to open the settings editor in json, where are the rest of my settings including the default language settings?
Other info
I looked at this link, but the solution did not help.
I do not think it matters, but I am using the SAS-Syntax extension for my syntax highlighting.
Solution
Specifying the language is case-sensitive. I previously was using the lower-case sas but it must be the upper-case SAS. The functional JSON is below:
{
"editor.insertSpaces": false,
"editor.wordWrap": "on",
"workbench.settings.editor": "json",
"files.associations": {
"*.sas": "SAS"
},
"files.defaultLanguage": "SAS"
}


