简体   繁体   English

在 Visual Studio 代码中格式化 ejs

[英]Formmating ejs in visual studio code

Hi, I need to indent my ejs code in visual studio, but I get this message: "Sorry, but there is no formatter for 'ejs'-files installed"嗨,我需要在 Visual Studio 中缩进我的 ejs 代码,但我收到以下消息:“抱歉,没有安装 'ejs'-files 的格式化程序”

I already installed EJS Language Support but it just colored the code, not indent.我已经安装了 EJS 语言支持,但它只是为代码着色,而不是缩进。

Does anyone know how to do this in Visual studio code?有谁知道如何在 Visual Studio 代码中执行此操作?

thanks.谢谢。

Step 1第1步

Click File >> Preferences >> Settings You will get something like this点击文件>>首选项>>设置你会得到这样的东西在此处输入图片说明

Step 2第2步

The Textbox "search settings" type in settings.json文本框“搜索设置”形settings.json 在此处输入图片说明 Click Edit in settings.json单击Edit in settings.json


add this in the settings.json just below在下面的 settings.json 中添加这个


"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
 //Add this below
"files.assocations": {
        "*.ejs": "html"
    },

Reload the Visual Code Editor and you are good重新加载可视化代码编辑器,你很好

try the following link: FORMATTING “.EJS” FILE IN VS CODE (VISUAL STUDIO CODE)尝试以下链接: 在 VS 代码中格式化“.EJS”文件(视觉工作室代码)

In short, you may need to add this to your settings (ctrl/cmd + ,):简而言之,您可能需要将其添加到您的设置中 (ctrl/cmd + ,):

"files.associations": {
    "*.ejs": "html"
},

Formatting EJS like HTML not work.像 HTML 一样格式化 EJS 不起作用。 Ok, no longer displays an error, but generate a bad formatting.好的,不再显示错误,而是生成错误的格式。

Examples:例子:

  1. Other post: Wrong indentation on EJS files with VSCode其他帖子: 使用 VSCode 对 EJS 文件进行错误缩进

  2. simple code: https://github.com/microsoft/vscode/issues/24013简单代码: https ://github.com/microsoft/vscode/issues/24013

  3. see last image, form parameters: https://www.sung.codes/blog/2018/formatting-ejs-file-vs-code-visual-studio-code看最后一张图片,表单参数: https ://www.sung.codes/blog/2018/formatting-ejs-file-vs-code-visual-studio-code

We need a plugin.我们需要一个插件。 "EJS Language Support" plugin it also doesn't work on formatting. “EJS 语言支持”插件也不适用于格式化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM