3 Inserting end-tags

The main redundancy in XML syntax is end-tags. nXML mode provides several ways to make it easier to enter end-tags. You can use all of these without a schema.

You can use C-M-i after ‘</’ to complete the rest of the end-tag.

C-c C-f inserts an end-tag for the element containing point. This command is useful when you want to input the start-tag, then input the content and finally input the end-tag. The ‘f’ is mnemonic for finish.

If you want to keep tags balanced and input the end-tag at the same time as the start-tag, before inputting the content, then you can use C-c C-i. This inserts a ‘>’, then inserts the end-tag and leaves point before the end-tag. C-c C-b is similar but more convenient for block-level elements: it puts the start-tag, point and the end-tag on successive lines, appropriately indented. The ‘i’ is mnemonic for inline and the ‘b’ is mnemonic for block.

Finally, you can customize nXML mode so that / automatically inserts the rest of the end-tag when it occurs after ‘<’, by doing

M-x customize-variable RET nxml-slash-auto-complete-flag RET

and then following the instructions in the displayed buffer.