I'm trying to create a snippet in Visual Studio Code. This works, but the indentation is missing:
My snippet :
"HTML structure": {
"prefix": "html",
"body": [
"<!DOCTYPE html>",
"<html lang='fr'>",
"<head>",
"<meta charset='UTF-8'>",
"<meta name='viewport' content='width=device-width, initial-scale=1.0'>",
"<meta http-equiv='X-UA-Compatible' content='ie=edge'>",
"<title>$1</title>",
"</head>",
"<body>",
"$2",
"</body>",
"</html>"
],
"description": "Base template for html file"
}
What you see :
<!DOCTYPE html>
<html lang='fr'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<meta http-equiv='X-UA-Compatible' content='ie=edge'>
<title>test</title>
</head>
<body>
test
</body>
</html>
What I'd like :
<!DOCTYPE html>
<html lang='fr'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<meta http-equiv='X-UA-Compatible' content='ie=edge'>
<title></title>
</head>
<body>
</body>
</html>
I think the more appropriate way is to use \t
instead of space to maintain document indentation even.
"\t<meta charset='UTF-8'>",
The indentation needs to be inside of the strings, not outside (where it's meaningless), so:
" <meta charset='UTF-8'>",
instead of:
"<meta charset='UTF-8'>",
This works as intended:
"HTML structure": {
"prefix": "html",
"body": [
"<!DOCTYPE html>",
"<html lang='fr'>",
"<head>",
" <meta charset='UTF-8'>",
" <meta name='viewport' content='width=device-width, initial-scale=1.0'>",
" <meta http-equiv='X-UA-Compatible' content='ie=edge'>",
" <title>$1</title>",
"</head>",
"<body>",
" $2",
"</body>",
"</html>"
],
"description": "Base template for html file"
}
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