Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single Quotes in Emmet With VS Web Essentials

Is there a way how to force Visual Studio Web Essentials to insert single quotes instead of double quotes?

For instance so that div.col-xs-1 TAB produces <div class='col-xs-1'></div> instead of default <div class="col-xs-1"></div>?

I am using Visual Studio 2013 Update 4 with Web Essentials 2013 v. 2.5.3.

like image 973
grizzly Avatar asked Jun 18 '15 20:06

grizzly


People also ask

How do you make Emmet single quotes?

To get single quotes working with JSX you will need to update or create the syntaxProfiles. json in ~/emmet with the syntax profile. If ~/emmet does not exist create it. The key is the file extension and the value is the name of the profile that extension will use.

How do I use single quotes in HTML?

You could use HTML entities: &#39; for ' &#34; for "

Does JSON work with single quotes?

Strings in JSON are specified using double quotes, i.e., " . If the strings are enclosed using single quotes, then the JSON is an invalid JSON .


2 Answers

Not to be a johnny come lately, but I was having trouble getting this to work in VS code, and so I thought I would post a solution for anyone still having this problem. My solution was to go into settings (ctrl-,) > user settings > extensions > emmet and under preferences click "Edit in settings.json". There, I added this to the user settings:

"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
    }
}

Where each language you can define settings for. This worked for me.

like image 131
Marco Principio Avatar answered Oct 20 '22 23:10

Marco Principio


To get single quotes working with JSX you will need to update or create the syntaxProfiles.json in ~/emmet with the syntax profile. If ~/emmet does not exist create it.

The key is the file extension and the value is the name of the profile that extension will use.

So in ~/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"
}

And in ~/emmet/profiles.json

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

This should work for most editors but I have only tried in atom. https://github.com/emmetio/emmet-atom/issues/68

like image 26
Jonny Avatar answered Oct 21 '22 01:10

Jonny