On Tue, 16 May 2006, Ivan Vecerina wrote:
Hi,
I'm pretty new to Vim, but went through several tutorials, quick
references, a number of help pages, and briefly through the Vim book. I
also hear announcements about Vim7's enhanced built-in support for HTML
editing. I even tried to play a bit with the auto-completion (got some
'completion lists' popping up after opening a PHP/HTML file...).
But where do I go from here to learn efficient HTML editing with Vim,
having expert around to receive guidance from?
IMHO, in order to learn efficient HTML editing with Vim, or any other
type of editing for that matter, you should master Vim's basic
operations and practice them regularly. You could read Bram Moolenaar's
"Seven Habits of Effective Text Editing" at:
http://www.moolenaar.net/habits.html
Also recommended is the Vim FAQ at:
http://vimdoc.sourceforge.net/htmldoc/vimfaq.html
The FAQ contains some obscure information that goes beyond your average
Vim cheat sheet. You can try to answer the FAQs to see if you REALLY
know Vim ;)
I've put together the information above in a Vim tip at:
http://www.vim.org/tips/tip.php?tip_id=1172
Especially when it comes to Vim7, all tutorials I have seen seem terribly
outdated.
For example, here are a few simple things I need to do all the time:
- Insert tags around a selected block of text (e.g. <b>...</b>)
This came up very recently on this mailing list twice. You can read the
recent thread at:
http://groups.yahoo.com/group/vim/message/68627
Take note of
http://www.vim.org/tips/tip.php?tip_id=346
- get vim to automatically close/complete the innermost previously opened
tag.
Good suggestion mentioned by Tony.
- delete both the start and end tag with a minimum number of keystrokes.
I think using matchit is one of the fastest ways to delete block-like
items, including start and end tags.
http://www.vim.org/scripts/script.php?script_id=39
For example, to delete from a start tag to an end tag, place the cursor
on the start tag and hit "d%".
To only delete the tags, place the cursor on the start tag, hit "%" and
delete the end tag. Then hit Ctrl-o and delete the start tag.
I could find half a dozen of ways to do the above, and even more posts
about ways to semi-automate this.
But those most common operations ought to be well supported in Vim7 I
imagine, is there a good default way to accomplish them?
In order to obtain more support for operations involving HTML tags, you
could search in
http://www.vim.org/scripts/index.php
The good "default" way of accomplishing editing tasks is YOUR way of
accomplishing editing tasks. Make Vim work for you, not the other way
around :) Other IDEs have long subdued users into thinking that there is
often a good default way of doing things. The Vim way is different.
Other things I don't know how to find is: how do I make sure that VIM
finds the CSS associated with the document I am editing (to help with
auto-completion)?
Someone else may be able to help you with this.
What are other tricks I should know for HTML-style document editing, and
where can I learn them?
Are there any targeted tutorials I should look into?
Is there an obvious resource I should use?
If you have time, you can look through
http://www.vim.org/tips/index.php
to get a feel of what other users want and have made out of Vim.
Also, stay on this mailing list and you will learn a lot.
HTH :)
--
Gerald