Emmet和VS Web Essentials中的单引号

11

有没有办法强制Visual Studio Web Essentials插入单引号而不是双引号?

例如,div.col-xs-1TAB会产生<div class='col-xs-1'></div>而不是默认的<div class="col-xs-1"></div>

我正在使用Visual Studio 2013更新4和Web Essentials 2013 v. 2.5.3。

2个回答

19

不想过于晚加入,但在VS code中我遇到了困难,所以我想为仍然有此问题的人提供解决方案。我的解决方案是进入设置(ctrl-,)> 用户设置> 扩展程序> emmet,在首选项下点击“在settings.json中编辑”。在那里,我将此添加到用户设置中:

"emmet.syntaxProfiles": {
    "xml": {
        "attr_quotes": "single"
    },
    "html": {
        "attr_quotes": "single"
    },
    "js": {
        "attr_quotes": "single",
        "self_closing_tag": true
    },
    "jsx": {
        "attr_quotes": "single",
        "self_closing_tag": true
    }
}

每种语言都可以定义设置。这对我有用。


2
谢谢,我陷入了一个深深的兔子洞里试图解决这个问题。这是帮助我的解决方案(VS Code ver 1.42.0)。为了明确起见,我将您提供的代码添加到我的settings.json文件中,而不是创建一个单独的文件或目录。 - Anthony
谢谢!我按下ctrl + shift + p进入弹出窗口。我搜索了“settings json”。点击“Preferences: Open Settings (JSON)”。然后在底部添加了上述设置,它完美地工作了。 - Nhon Ha
1
这个问题涉及在 Visual Studio 中使用 VS Web Essentials(而非 VS Code)。 - glenho123
在 VS Code 中无法工作。 - fdrv
这是唯一一个对我起了魔法般作用的可行解决方案。谢谢! - terryeah

2
为了让JSX支持单引号,您需要更新或创建syntaxProfiles.json文件,并在其中添加语法配置。如果~/emmet目录不存在,则需要先创建该目录。
文件扩展名是关键字,对应的值是该扩展名所使用的语法配置名称。
因此,在~/emmet/syntaxProfiles.json中添加如下内容:
/* 'js' will map files with .js extension to use the js profile*/
/* 'jsx' will map files with .jsx extension to also use the js profile*/
{
  "js": "js",
  "jsx": "js"
}

~/emmet/profiles.json

/* create or add the 'js' profile */
{
  "html": {
    "attr_quotes": "double"
  },
  "js": {
    "attr_quotes": "single",
    "self_closing_tag": true
  }
}

这应该适用于大多数编辑器,但我只在atom中尝试过。 https://github.com/emmetio/emmet-atom/issues/68


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接