Automatically insert closing tags in HTML / XML / XSL


#1

I’ve been writing quite a bit of HTML / XML / XSL recently, and I’m finding that it’s a chore having to close all my tags (such as <xsl:template></xsl:template> and <html></html>) manually.

Is there a package that will do this for me?

Thanks.


#2

People have been reporting good things about the less-than-slash package.


#3

I feel personally like the most hygienic way to write tree-structured languages is to insert both tags at once, and snippets work great for that.


#4

less-than-slash looks good, but as @DamnedScholar says inserting both tags at once would be preferable. Sadly that’s not possible when writing XML, as you can’t predict the tag name that you’ll be using ahead of time.


#5

It most certainly is possible. When you’re writing an XML document for a pre-defined schema, you can just make snippets for each of the tags you’ll be using most often. For everything else, try out this gem:

'.xml':
  'Blank Tag':
    prefix: '<?>'
    body: '<$1>$2</$1>'

Having $1 inside each tag creates two cursors that mirror everything you type. Then just type the tag name, press tab, and you’re in the middle.


#6

I hadn’t thought of that! I’m adding that to my snippets right now.


#7

https://atom.io/packages/close-tags or https://atom.io/packages/autoclose-html

The latter is unmaintained and does not support multiple cursors


#8

Thanks!

The former looks like just what I was after.