Vim Tips Wiki

Section jump in Latex

Redirected from VimTip489

1,624pages on
this wiki
Add New Page
Talk0 Share
Tip 489 Printable Monobook Previous Next

created June 19, 2003 · complexity basic · version 

This is a small mapping that can be used for jumping sections in a latex file.

map <silent> ]s :/\\\(sub\)\{,2}section\s*{<CR> :noh<CR>
map <silent> [s :?\\\(sub\)\{,2}section\s*{<CR> :noh<CR>

The above commands don't work with a count. The following maps correctly work with a count and also update the pattern. Also, if you want to keep the original search pattern, just comment out the "let @/ = pat" line.

" section jumping
noremap <buffer> <silent> ]] :<c-u>call TexJump2Section( v:count1, '' )<CR>
noremap <buffer> <silent> [[ :<c-u>call TexJump2Section( v:count1, 'b' )<CR>
function! TexJump2Section( cnt, dir )
  let i = 0
  let pat = '^\s*\\\(part\|chapter\|\(sub\)*section\|paragraph\)\>\|\%$\|\%^'
   let flags = 'W' . a:dir
   while i < a:cnt && search( pat, flags ) > 0
     let i = i+1
   let @/ = pat

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki