Closing HTML tags?

23 views
Skip to first unread message

Adolfo Olivera

unread,
Nov 13, 2012, 6:30:39 PM11/13/12
to vim...@googlegroups.com
Hi,
   I finally figured out how to use omnifunc for php, html, css. My question is: Once I open an HTML tag, is there a way of autogenerating the closing one?

Thanks,

Tony Mechelynck

unread,
Nov 13, 2012, 6:50:50 PM11/13/12
to vim...@googlegroups.com, Adolfo Olivera
I use the CloseTag plugin,
http://www.vim.org/scripts/script.php?script_id=13 -- which you could
have found by going to http://www.vim.org/ then "Scripts" then search
for "closetag".


Best regards,
Tony.
--
The average income of the modern teenager is about 2 a.m.


Benjamin Klein

unread,
Nov 13, 2012, 7:15:07 PM11/13/12
to vim...@googlegroups.com
I could be dreadfully wrong about this but tag-closing functionality seems like a rather small feature to be available only in its own specific plugin. I therefore ask out of curiosity: Are there any other plugins that handle this?

--
b

Sent from my iPhone
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php

Tony Mechelynck

unread,
Nov 13, 2012, 8:11:45 PM11/13/12
to vim...@googlegroups.com, Benjamin Klein
On 14/11/12 01:15, Benjamin Klein wrote:
> I could be dreadfully wrong about this but tag-closing functionality seems like a rather small feature to be available only in its own specific plugin. I therefore ask out of curiosity: Are there any other plugins that handle this?

I don't know; but this "small" plugin will search backwards as far as
necessary for the latest unclosed open tag, and give an error if it
finds an opening tag not matching what was expected from a
not-yet-opened closing tag: put the cursor just before your </html> tag
then hit Ctrl-_ and if (possibly after some time) the plugin inserts
</html> with no error, it means you haven't left any mismatched tags in
the whole document. Otherwise (assuming you have a properly closed
</body> tag) it will try to stop with the cursor near the place where
you opened a tag which you have forgotton to close.

This plugin has a provision for "optionally closed" HTML tags (<p>,
<li>, <tr>, <td>, etc.); you may customize the list. XML of course
allows no such optionally closed tags: you have to either specify
explicitly that a <tag/> will have no content, or else <tag>open and
close it</tag> explicitly.


A similar small-but-not-so-small plugin (distributed with Vim) is the
matchit plugin, which will move the cursor from an open or closed
bracket or word to its mate depending on the file's syntax.


Best regards,
Tony.
--
Afternoon, n.:
That part of the day we spend worrying about how we wasted the
morning.

stosss

unread,
Nov 13, 2012, 9:39:08 PM11/13/12
to vim...@googlegroups.com

I have created my own maps to do html tags for the most common ones used.

stosss

unread,
Nov 13, 2012, 10:54:39 PM11/13/12
to vim...@googlegroups.com
On Tue, Nov 13, 2012 at 9:39 PM, stosss <sto...@gmail.com> wrote:
> I have created my own maps to do html tags for the most common ones used.
>
Sorry about the top post. I was using my smart phone and realized the
mistake as soon as I sent it.

Ben Fritz

unread,
Nov 14, 2012, 9:26:51 AM11/14/12
to vim...@googlegroups.com
On Tuesday, November 13, 2012 5:31:00 PM UTC-6, Adolfo Olivera wrote:
> Hi,
>
>    I finally figured out how to use omnifunc for php, html, css. My question is: Once I open an HTML tag, is there a way of autogenerating the closing one?
>

Using the default HTML omni completion on </ will automatically close the last open tag. E.g. with text "<span>My fun span</" typing CTRL-X CTRL-O will complete to "<span>My fun span</span>". Is this what you're looking for?

Adolfo Olivera

unread,
Nov 14, 2012, 4:56:58 PM11/14/12
to vim...@googlegroups.com
Thanks to all for the tips. I guess I'll try installing one of the mentioned plugins.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php



--
Adolfo Olivera
15-3429-9743



Reply all
Reply to author
Forward
0 new messages