Change HTML + Tab autocomplete (Sublime Text 2) - autocomplete

When you type out the word like so
and then press tab it autocompletes to something like so...
But I want it to look something more along the lines of this

This is one of Sublime's built in snippets. You can edit the default one or create a new one. To edit the existing,
Preferences > Browse Packages
Open HTML folder
Edit html.sublime-template
The default snippet is below:
<snippet>
<content><![CDATA[<html>
<head>
<title>$1</title>
</head>
<body>
$0
</body>
</html>]]></content>
<tabTrigger>html</tabTrigger>
<scope>text.html</scope>
</snippet>
The content you want to edit is between <![CDATA[ and ]]>. The $0 and $1 variables are placeholders for content and once Sublime Text renders the snippet, you can move between the placeholders by pressing tab.

Related

How do I remove Django HTML as an option in the VSCode Select Language Mode?

VSCode is still very new to me. Every time I open ah HTML document from my class assignments (or any ordinary HTML document for that matter) VSCode defaults to "Django HTML" over regular "HTML" formatting.
I'd like to remove Django HTML as the default so that any time I open up a .html document the default formatting is regular HTML.
First type CRTL + K, then press M
Click "Configure File Association '.html'..."
Type "HTML" into the search bar
Select "<HTML>"
If you do the same first 3 steps again, you should now see "<HTML> Current Default" which confirms that you have done these steps correctly.
Add this to your settings.json
"files.associations": {
"*.html": "html",
}

How to select content of HTML attribute with single shortcut press in VSCode?

I can't find out how to select the whole content of HTML attribute. For example I have a div with class
<div class="menu-link font-size-bigger font-weight-bold"></div>
So now when I want to select all classes "menu-link font-size-bigger font-weight-bold" I must press smartSelect.grow 3x
Is there a better way. I just want to use one shortcut press. Thank you
For this use case you need to install an extension. You could try these:
https://marketplace.visualstudio.com/items?itemName=chunsen.bracket-select
https://marketplace.visualstudio.com/items?itemName=StAlYo.select-quotes

Keyboard Shortcut to Surround Selection with HTML Tag

Desired Steps:
Highlight (select) HTML/text, e.g. really
Press keyboard shortcut
Highlighted text becomes <b>really</b>
How to?
In a Javadoc comment you can just select the text which you want to wrap in a <b> tag and press CTRL+Space. Select the <b> template, press Enter and the selected text gets surrounded as expected. There are pre-defined templates for <b>, <code>, <i> and <pre>. You can define your own templates here: Java -> Editor -> Templates.
You're looking for Quick Fix/Quick Assist: Ctrl/Cmd+1. Then start typing the tag name.

How to auto indent nested HTML tags in VS Code

I'm trying out VS Code and I used Emmet to create a new HTML element with a class. I need to create another nested (child) HTML element inside the original element, but by default, VS Code will not indent for the new element, when you hit enter inside the original element tags. Like if you have <div class="main"></div> and you hit enter in between the div tags, you'll get -
<div class="main">
</div>
And then you need to manually go one line up, add tabs and indent for the new HTML element.
In Webstorm, hitting enter in between the parent tags automatically indents for the new child element.
Here are two GIFs which show what I mean.
VS Code -
Webstorm -
Is there an extension or some other trick that achieves this feature in VS Code?
Download an HTML formatter Extension. 1th, download one of the below Extensions:
Beautify
JS-CSS-HTML Formatter
OR any other HTML formatter you want. 2th, in VS Code, go to one of the HTML files you are working. 3th, Press ALT + SHIFT + F then a pop out window appears. 4th select one of the suggested formatters. All done!
Whenever, you press ALT + SHIFT + F in an HTML file, it will be auto indented and beautified.
I'm guessing your looking for this setting
{
...
"html.format.indentInnerHtml": true,
...
}
"emmet.useNewEmmet": true;
Use this command to enable indent.
Steps:
1) Open "settings.json".
2) Add this code inside { ..... } (Curly Braces).
3) Make sure you add ',' (comma) on the last line if you are adding this code after a certain line in the end.
eg:
{
...
...
"editor.fontSize": 17, <--comma
"emmet.useNewEmmet": true
}
4) Save it.
FROM: https://github.com/Microsoft/vscode/issues/30790#issuecomment-317290906

How to surround some html code in Eclipse with new tag (shortcut)?

I want to surround some HTML code with <div> - how to do it in Eclipse with some shortcuts or macros. I do not want to repeat surrounding manually.
<p>some text</p>
I want to surround with <div> and achieve
<div><p>some text</p></div>
Follow below mentioned steps :
Select the text that you want to surround with tag.
Go to 'Edit > Quick Fix' or press 'Ctrl + 1'.
Double click "Surround with new element"