Auto-close HTML tags in Sublime Text

sublime-text-2

I'm using Sublime Text 2, and I'm sure there must be a way to make it auto-close XML/HTML tags, the way for example Notepad++ can.

Is there a way to have it add </div> immediately after I type <div>?

Best Answer

As zoli's answer states, you can use snippets/completions to auto complete tags as you start typing them. But there should be some built into sublime. For example, as you start to type <div>, you should see a drop down box with matching snippets. Hit Tab or Enter to pick one and arrow keys to go up or down in the list. For html tags, it will automatically adds the closing tag and puts the cursor in between them.

Another option is: use Edit > Tag > Close Tag. The hotkeys are displayed in the file menu. It automatically adds the closing tag if you already added an opening tag.