Search code examples
visual-studio-codeemmet

Is it possible to use emmet's lorem in javascript's strings?


I'd like emmet to help me with this:

const str = 'lorem5|TAB'; --> const str = 'Lorem ipsum dolor sit amet.';

| cursor position

TAB hitting tab

Is it possible in VSCode? It works for me only with jsx and html.


Solution

  • You can but there are probably better ways to do this (such as dedicated extensions)


    To use emmet, just enable emmet in *.js files by setting:

    "emmet.includeLanguages": {
        "javascript": "javascriptreact"
    }
    

    Now the lorem abbreivation will work:

    The lorem abbreivation

    And if you have "emmet.triggerExpansionOnTab": true set, then you can hit tab to expand the text.

    However Emmet completions will not show up for the case you showed: the string "lorem5". The reason is that emmet sees the closing " immediately after the abbreviation so it decides not to return any completions. Instead, you have to use the Emmet: Expand Abbreviation command (which is bound to tab by default) to force emmet to expand lorem5:

    enter image description here

    enter image description here