Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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 '12 at 0:51
Related: How to jump between matching HTML/XML tags? at Vim SE – kenorb Feb 14 '15 at 0:29
up vote 9 down vote accepted
  • 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.

share|improve this answer

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:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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