Auto code formatting (action editor.action.format
) breaks Jekyll (aka Github Pages) pages YAML front matter.
index.html before auto formatting:
---
layout: default
title: Awesome page
bodyClass: homepage
permalink: /
---
(rest of the content)
index.html after autoformatting:
--- layout: default title: Awesome page bodyClass: homepage permalink: / ---
(rest of the content is formatted ok, regular html syntax)
How can I tune up the VS code formatting rules?
Auto formatting settings in Visual Studio Show activity on this post. Select the text you want to automatically indent. Click menu Edit → Advanced → *Format Selection, or press Ctrl + K , Ctrl + F . Format Selection applies the smart indenting rules for the language in which you are programming to the selected text.
Step 1 — Using the Format Document Command To open the command palette, you can use COMMAND + SHIFT + P on macOS or CTRL + SHIFT + P on Windows. In the command palette, search for format and then choose Format Document. Then choose Prettier - Code Formatter.
To resolve this, you have two options:
Turned off formatting of HTML files in settings.json
file:
"html.format.enable": false
This turns off formatting off for HTML files. Not ideal, but gets the job done. There's a GitHub Issue for this, but it looks to have been closed.
Consider installing the Liquid Languages Support extension then adding this to your settings.json
:
"files.associations": {
"*.html": "liquid"
}
This has resolved the issue for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With