" " nextag.vim - Move to next and previous tags in a SGML document, including " XML and HTML. Use , and . to search for the previous and " next HTML tags, respectively. Prepended counts work, e.g. 5. " " Maintainer: Tom Ryder " " " Wrapper to prevent overloading and signal our presence, and check we're not " in compatible mode or running a version of Vim that's too old. " if exists("g:loaded_nextag") || &compatible || (v:version < 700) finish endif let g:loaded_nextag = 1 " " Search for a SGML tag with the specified flag. " function! s:MoveToSGMLTag(direction, mode, count) if a:mode == 'v' normal! gv endif let l:flags = (a:direction == "next") ? "W" : "Wb" for l:iteration in range(1, a:count) call search("<\w*[^>]*>", l:flags) if a:mode == 'v' if a:direction == 'next' && &selection != 'exclusive' normal! l endif endif endfor if a:mode == 'v' if a:direction == 'next' && &selection != 'exclusive' normal! h endif endif endfunction " " Default remappings. " for s:mode in ['n', 'o', 'v'] execute s:mode . 'map . :call MoveToSGMLTag("next", "' . s:mode . '", v:count1)' execute s:mode . 'map , :call MoveToSGMLTag("prev", "' . s:mode . '", v:count1)' endfor