Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

visual studio code - Is it possible to associate a given language with a file extension in VSCode?

Is it currently possible to associate a given language with a file extension that is not typically associated with that language?

Say I have a filetype *.foo, and I want to associate it with JavaScript for syntax highlighting. Does anyone know if this is currently possible with VSCode?

I am working in a language that is syntactically similar to Visual Basic, and want to associate it with that language type. I understand that you can assign a language after the file is opened, however this is cumbersome to do each time a file is opened.

In Sublime Text for example it is possible to select "Open all with current extension as...". Does this exist yet for VSCode?

EDIT: The Visual Studio Code team has added a proper way to add both themes and languages.

https://code.visualstudio.com/updates#_yo-code-streamlined-customizations-for-vs-code

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

VSCode v1.0 officially adds the File to Language Association feature. Add the following into .vscode/settings.json:

"files.associations": {
    "*.foo": "javascript"
}

You may find more details in the Visual Studio Code 1.0.0 release notes “File to language association” section.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...