Just like editing C source file, I can press % to get the closing } for the current cursor's {. How can I do this when editing html files? Is there any shortcuts? To be clear, I want:
<html>
</html>
When the curosr moves to <html>
, I want to press a key, so that the cursor will jump to </html>
.
An opening tag begins a section of page content, and a closing tag ends it. For example, to markup a section of text as a paragraph, you would open the paragraph with an opening paragraph tag <p> and close it with a closing paragraph tag </p> (closing tags always proceed the element with a /).
The br tag inserts a line break (not a paragraph break). This tag has no content, so it is self closing.
You can jump between tags using visual operators, in example:
Your cursor should jump forward to the matching closing html/xml tag. To jump backwards from closing tag, press o or O to jump to opposite tag.
Now you can either exit visual by pressing Esc, change it by c or copy by y.
To record that action into register, press qq to start recording, perform tag jump as above (including Esc), press q to finish. Then to invoke jump, press @q.
See more help at :help visual-operators
or :help v_it
:
at a
<tag> </tag>
block (with tags)it inner
<tag> </tag>
block
Alternatively use plugin such as matchit.vim (See: Using % in languages without curly braces).
See also:
You should be able to do this with the matchit plugin by typing % when your mouse is on the opening tag.
http://www.vim.org/scripts/script.php?script_id=39
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With