Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emmet abbreviation syntax multiplication puts all elements on same line instead of multiple?

Everywhere I see people use Emmet abbreviations in VS Code the behavior of the code editor is the same. If someone puts the following code,

a:link*3

The result is the following

<a href="http://"></a>
<a href="http://"></a>
<a href="http://"></a>

Yet when I try it within my own copy of VS Code it seems to distribute them without a return on the same line.

<a href="http://"></a><a href="http://"></a><a href="http://"></a>

Is there any way to modify this behavior within the setting? I'm not sure if it matters but I'm on version 1.53.0-exploration on an Apple M1 MBA.

like image 887
Kyle J Avatar asked Feb 13 '21 00:02

Kyle J


People also ask

How do I set attributes in Emmet?

Emmet can use [attr] notation (as in CSS) to add custom attributes to your elements, for example for a link. It is useful to add default values to elements. You can place as many attributes as you like inside square brackets [ ] .

How do you use Emmet abbreviations in Visual Studio code?

Open the VS Code settings (Code → Preferences → Settings) and search for “Emmet Extensions Path”. Click “Add Item”, enter the path to the folder where you've saved the snippets. json file you've created earlier and press “OK”.

How do you add text to Emmet?

You can use curly braces to add text to an element. Show activity on this post. Show activity on this post.

Which abbreviation syntax multiplication puts all elements on same line?

Emmet abbreviation syntax multiplication puts all elements on same line instead of multiple? Everywhere I see people use Emmet abbreviations in VS Code the behavior of the code editor is the same. If someone puts the following code,

What are abbreviations in Emmet?

Abbreviations are the heart of the Emmet toolkit: these special expressions are parsed in runtime and transformed into structured code block, HTML for example. The abbreviation’s syntax looks like CSS selectors with a few extensions specific to code generation. So every web-developer already knows how to use it. ...with just a single key stroke.

How to use Emmet for HTML?

Emmet for HTML: 1. Creating an element by its name: In HTML, as you type in the name of the HTML tag, you will get a suggestion list, select the element that you want to insert from the suggestion list. For example, if you type h1 and click enter to get the <h1></h1>. You can do this for all HTML tags as well.

How to remove line markers in Emmet using VS Code?

in VS Code, you would use a simpler: "emmet.preferences": {"filter.commentAfter": " \n <!-- /[#ID][.CLASS] -->"} Trim filter (t) This filter is applicable only when providing abbreviations for the Emmet: Wrap Individual Lines with Abbreviation command. It removes line markers from wrapped lines. Using custom Emmet snippets


2 Answers

try this solution, it worked for me:

go to settings.json and apply this setting:

"emmet.syntaxProfiles": {

    "html": {
        //if element created is more than 2, it will break to new line for each element
        "inline_break": 2,
    }
}

i read it from the documentation:

inline_break: how many inline elements are needed to force line break, number. The default value is 3. For example, span2 will be expanded into , but span3 will create three elements, each on a new line. Set this option to 0 to disable line breaks for inline elements.

https://docs.emmet.io/customization/syntax-profiles/#create-your-own-profile

like image 102
Tai Avatar answered Oct 09 '22 04:10

Tai


"emmet.preferences": {
  "output.inlineBreak": 1
}

This appears to be the better technique, see https://github.com/microsoft/vscode/issues/119088#issuecomment-811297787 as the emmet.syntaxProfiles and inline_break isn't actually supported by emmet itself but an addition in vscode. So it may be deprecated at some point in favor of emmet.preferences approach.

like image 6
Mark Avatar answered Oct 09 '22 04:10

Mark