mik*_*ebz 66 visual-studio-code
我在Mac上使用Visual Studio Code来处理Node.js应用程序.
有没有办法让Visual Studio Code将EJS文件识别为HTML标记?我没有在用户首选项中看到任何文件/方案关联.
tec*_*rek 107
实际上,你可以.
正如Andre指出的那样,现在您可以在工作区设置中执行此操作.转到Visual Studio代码设置: File >> Preferences >> User Settings
// Place your settings in this file to overwrite the default settings
{
// Configure file associations to languages (e.g. "*.extension": "html"). These have precedence over the default associations of the languages installed.
"files.associations": {"*.ejs": "html"}
}Run Code Online (Sandbox Code Playgroud)
单击VS Code窗口底部的"纯文本"选项卡并将其更改为HTML,屏幕截图如下:
And*_*eis 64
转到Visual Studio代码设置.文件>>首选项>>用户设置
在settings.json中添加此行.
// Place your settings in this file to overwrite the default settings
{
// Configure file associations to languages (e.g. "*.extension": "html"). These have precedence over the default associations of the languages installed.
"files.associations": {"*.ejs": "html"}
}
Run Code Online (Sandbox Code Playgroud)
重新启动Visual Studio代码.
小智 27
.ejs支持有一个扩展名.启动VS Code Quick Open(Ctrl + P),粘贴以下命令,然后键入enter.
ext install ejs-language-support
Run Code Online (Sandbox Code Playgroud)
小智 20
按照文档给出的指示, 我更改了此文件c:\ Program Files(x86)\ Microsoft VS Code\resources\app\extensions\html\package.json,所以它看起来像这样:
{
"name": "html",
"version": "0.1.0",
"publisher": "vscode",
"engines": { "vscode": "*" },
"extensionDependencies": [
"html"
],
"contributes": {
"languages": [{
"id": "html",
"aliases": ["ejs"],
"extensions": [".ejs"]
}]
}
}
Run Code Online (Sandbox Code Playgroud)
试过......为我工作..懒得创建一个新的文件夹atm
html在VSCode extensions文件夹中找到扩展名:
../app/extensions/html
在MacOS X上是
/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/html
在Windows上
c:\Program Files(x86)\Microsoft VS Code\resources\app\extensions\html\package.json
现在编辑文件package.json添加.ejs的extensions唯一的数组:
{
"name": "html",
"version": "0.1.0",
"publisher": "vscode",
"engines": { "vscode": "*" },
"contributes": {
"languages": [{
"id": "html",
"extensions": [ ".html", ".htm", ".shtml", ".mdoc", ".jsp", ".asp", ".aspx", ".jshtm", ".ejs" ],
"aliases": [ "HTML", "htm", "html", "xhtml" ],
"mimetypes": ["text/html", "text/x-jshtm", "text/template", "text/ng-template"]
}],
"grammars": [{
/* "language": "html", not yet enabled*/
"scopeName": "text.html.basic",
"path": "./syntaxes/HTML.plist"
}]
}
}
Run Code Online (Sandbox Code Playgroud)
顺便说一句,正确的方法应该是ejs extension在extensions文件夹中创建一个然后添加:
ejs/
ejs/package.json
ejs/snippet/
ejs/snippet/ejs.json
ejs/syntaxes/
ejs/syntaxes/EJS.plist
Run Code Online (Sandbox Code Playgroud)
当然这应该有EJS语法/语法,但我们可以简单地复制html,所以从extensions文件夹:
cd html/
cp -r * ../ejs/
Run Code Online (Sandbox Code Playgroud)
在package.json随后也能像
{
"name": "ejs",
"version": "0.1.0",
"publisher": "vscode",
"engines": { "vscode": "*" },
"contributes": {
"languages": [{
"id": "ejs",
"extensions": [ ".ejs" ],
"aliases": [ "EJS", "ejs" ],
"mimetypes": ["text/html", "text/x-jshtm", "text/template", "text/ng-template"]
}],
"grammars": [{
"scopeName": "text.html.basic",
"path": "./syntaxes/EJS.plist"
}]
}
}
Run Code Online (Sandbox Code Playgroud)
所以改变syntaxes/HTML.plist只是复制到syntaxes/EJS.plist.
然后重启VSCode.
| 归档时间: |
|
| 查看次数: |
40605 次 |
| 最近记录: |