9

I've recently started using Sublime Text 3 instead of my old usual editor, Brackets. When I'm writing HTML in Brackets, I would type: (| represents the cursor)

<div>|

And Brackets would automatically generate the closing tag, like so:

<div>|</div>

If I pressed Enter after that, it would open and auto-indent the tag:

<div>
    |
</div>

I've seen several other answers that describe using a keyboard shortcut. But is there a way to do it completely automatically in Sublime Text 3?

Edit: The ability to do the second half of what I am describing is not a built-in feature of Brackets, but rather a plugin. Also, here is an example:

enter image description here

1
  • 2
    In my experience, it does not autocomplete as you asked for. But when you type say for example <title> blah blah blah then type "</" - it auto completes by adding "title>" - thus making it "</title>". Notepad++ does not even do that
    – Prasanna
    Aug 22, 2014 at 3:55

3 Answers 3

13

To get tag autocompletion (and a ton of other cool features), check out the Emmet plugin, formerly known as Zen Coding. For example, typing divTab gives you

<div>|</div>

and hitting Enter then gives you

<div>
    |
</div>

Its syntax is based on CSS selectors, so you can do quite complicated things quickly. #page>div.logo+ul#navigation>li*5>a{Item $}Tab would give you:

Emmet

2
  • Agree. I believe Emmet also auto closes a tag when you have an open tag and type </
    – rebellion
    Aug 23, 2014 at 22:25
  • This is an amazing plugin. It makes writing HTML as easy as writing Slim Template. Now if only it could making reading it easier.
    – steel
    Dec 18, 2014 at 17:28
0

There's a plugin that I use that will auto-close tags like described above named Auto Close.

You can install it via Package Control by searching for "Auto Close".

-1

I had the same issue in windows and may people in several forums suggested me to remove and reinstall Sublime 3. But issue not resolved. I don't know the cause of issue. it seems some problem occurred with the packages installed or settings configured. I got resolved the issue in this way.

In Windows 10

go to C:\Users\ YOUR_USER_NAME \AppData\Roaming\Sublime Text 3

Remove folders and contents from that folder it will resolve this issue.

In Linux

Please reverse the process described in https://packagecontrol.io/installation

There is some issue coursing with this is that all the installed packages will get removed. You need to reinstall needful packages again.

So please make sure to note down and reinstall all the plugins needed.

1
  • 2
    Please read the question again carefully. Your answer does not answer the original question. OPs install is not broken, he's asking for additional functionality.
    – DavidPostill
    Jul 4, 2016 at 9:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .