HTML editing and tag completion

310 views
Skip to first unread message

NM Public

unread,
Mar 3, 2008, 9:58:03 AM3/3/08
to vim...@googlegroups.com
Thanks to travis's post, I learned about Omni Completion. I've
been experimenting with it and it's not really what I want for
HTML editing and I wonder if you all could point me to some
features or scripts that would get Vim to do the following: When
I type the beginning of a tag, e.g.:

<ul

and then press a key, e.g. TAB, it would automatically be
expanded to this:

<ul><li> </li></ul>
^
cursor here

I've gotten spoiled by this in Dreamweaver, but I'm really trying
to escape from Dreamweaver and would love to just use Vim.

Any tips for efficient HTML editing are welcome.

Thank you,
Nancy

PS - I know this is a general Vim question rather than a MacVim
question, but I'm starting here because I mainly use MacVim and
this is where I learned about Omni Completion.

Nico Weber

unread,
Mar 3, 2008, 10:08:35 AM3/3/08
to vim...@googlegroups.com
> Thanks to travis's post, I learned about Omni Completion. I've
> been experimenting with it and it's not really what I want for
> HTML editing and I wonder if you all could point me to some
> features or scripts that would get Vim to do the following: When
> I type the beginning of a tag, e.g.:
>
> <ul
>
> and then press a key, e.g. TAB, it would automatically be
> expanded to this:
>
> <ul><li> </li></ul>
> ^
> cursor here
>
> I've gotten spoiled by this in Dreamweaver, but I'm really trying
> to escape from Dreamweaver and would love to just use Vim.
>
> Any tips for efficient HTML editing are welcome.

Lowtech solution:

:iabb ul <ul><li></li></ul><C-o>13h

After that, `ul` gets replaced by what you wrote. You might also want
to check out the snippets plugin: http://www.vim.org/scripts/script.php?script_id=1318
I haven't used it, but I heard good things about it.

Nico

Ted Pavlic

unread,
Mar 3, 2008, 10:31:42 AM3/3/08
to vim_mac
> <ul><li> </li></ul>
> ^
> cursor here


I know the Vim-LaTeX plugin comes with the ability to do exactly this. I
use it with LaTeX all the time.

From what I understand, it improves upon what's already in Vim. So, I
HIGHLY recommend you go to the main Vim list (or a FAQ).

--Ted


--
Ted Pavlic <t...@tedpavlic.com>

Matt Tolton

unread,
Mar 3, 2008, 11:28:53 AM3/3/08
to vim...@googlegroups.com
Additionally, the surround.vim plugin does wonders when editing these
kinds of files.

http://www.vim.org/scripts/script.php?script_id=1697

IMHO, this plugin should be included in the vim distribution (just as
matchit is).

Matt

Morel David

unread,
Mar 3, 2008, 10:32:33 AM3/3/08
to vim...@googlegroups.com

Le 3 mars 08 à 15:58, NM Public a écrit :

>
> Thanks to travis's post, I learned about Omni Completion. I've
> been experimenting with it and it's not really what I want for
> HTML editing and I wonder if you all could point me to some
> features or scripts that would get Vim to do the following: When
> I type the beginning of a tag, e.g.:
>
> <ul
>
> and then press a key, e.g. TAB, it would automatically be
> expanded to this:
>
> <ul><li> </li></ul>
> ^
> cursor here

http://www.vim.org/scripts/script.php?script_id=1318

D.Morel

travis

unread,
Mar 3, 2008, 12:00:05 PM3/3/08
to vim_mac
For HTML editing there's a few scripts you want.

SnippetsEmu - is exactly what you want, it's very similar to
TextMate's snippets, you can set it to that completion you want.
(http://www.vim.org/scripts/script.php?script_id=1318)
Surround - surrounding bunch of text and adding tags to them, you can
add your own commands as well to be faster. (http://www.vim.org/
scripts/script.php?script_id=1697)
HTML.vim - add's macros and menus (http://www.vim.org/scripts/
script.php?script_id=453)
xmledit - automatically closes tags when you type them in and if you
press another > after making a tag it automatically indents it for
you. (http://www.vim.org/scripts/script.php?script_id=301)

NM Public

unread,
Mar 5, 2008, 4:27:45 AM3/5/08
to vim...@googlegroups.com
Sur 2008-03-03, travis e'crit:

>
> For HTML editing there's a few scripts you want.
>
> SnippetsEmu - is exactly what you want [...]

Thank you all for all your excellent suggestions. I now need to
find some time to experiment with all these!

Long live Vim!
Nancy

Reply all
Reply to author
Forward
0 new messages