Is there a shortcut to jump from , e.g <XX> to </XX> ?

I already give it a try with '%' , but it doesn't work for this situation.

  • 2
    I think you'll need a plugin like matchit in order to be able to match XML tags. matchit itself seems to come with most vim distributions, but you'll still have to enable it yourself. :help matchit-install for more.
    – jw013
    May 9, 2012 at 0:51
  • Related: How to jump between matching HTML/XML tags? at Vim SE
    – kenorb
    Feb 14, 2015 at 0:29

2 Answers 2


You can jump between tags using visual operators, in example:

  1. Place the cursor on the tag.
  2. Enter visual mode by pressing v.
  3. Select the outer tag block by pressing a+t or i+t for inner tag block.

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:

  • Install the matchit plugin (see :help matchit-install for instructions).
  • Make sure automatic file-type detection and plugin-loading is enabled (:filetype plugin on).

Henceforth, whenever you edit a file detected as xml or html or some other tag-based markup language, the combination of the matchit plugin and the filetype plugin files will allow the % motion to match open and close tags.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.