Has anybody found out how to correctly autoindent .ejs in VS Code?

Viewed 132

Has anybody figured out how to have VS Code correctly auto-format .ejs files? I've followed the tips in this post, but nothing seems to be working for me.

1 Answers

Looks like the users in this thread was looking for such a way as well. The answer seems to be:

  1. Install EJS language support plugin
  2. Now you have ejs support, highlighting, and snippets, but some tags like
    <? for( let item of array ) { ?>
    (some data)
    <? } ?>

are formatted incorrectly (at least with default html formatter).

  1. To fix this, you can try set custom delimeter to '?' ejs.delimeter = '?'. Now you have correct indentation with <? ... ?> tags.

  2. To use the snippets with our custom delimeter, you need to edit extension snippets (or add your own): install Snippets Ranger plugin, then find needed extension and edit its file. The Snippets Ranger is very handy tool.

User Victor Gorban seems to be used to doing this so reaching out to him wouldn't be a bad idea.

Related