(Move categories to tip template) |
(Remove html character entities) |
||
Line 21: | Line 21: | ||
<pre> |
<pre> |
||
" section jumping |
" section jumping |
||
− | noremap |
+ | noremap <buffer> <silent> ]] :<c-u>call TexJump2Section( v:count1, '' )<CR> |
− | noremap |
+ | noremap <buffer> <silent> [[ :<c-u>call TexJump2Section( v:count1, 'b' )<CR> |
function! TexJump2Section( cnt, dir ) |
function! TexJump2Section( cnt, dir ) |
||
let i = 0 |
let i = 0 |
||
− | let pat = '^\\\(part\|chapter\|\(sub\)*section\|paragraph\)\ |
+ | let pat = '^\\\(part\|chapter\|\(sub\)*section\|paragraph\)\>\|\%$\|\%^' |
let flags = 'W' . a:dir |
let flags = 'W' . a:dir |
||
− | while i |
+ | while i < a:cnt && search( pat, flags ) > 0 |
let i = i+1 |
let i = i+1 |
||
endwhile |
endwhile |
Revision as of 08:48, 29 September 2008
Tip 489 Printable Monobook Previous Next
created June 19, 2003 · complexity basic · author Aditya Mahajan · version 6.0
This is a small mapping that can be used for jumping sections in a latex file (just like ]m and [m for Java methods).
map <silent> ]s :/\\\(sub\)\{,2}section\s*{<CR> :noh<CR> map <silent> [s :?\\\(sub\)\{,2}section\s*{<CR> :noh<CR>
Comments
Here is an excerpt from my tex ftplugin, where section jumping works with count. The search() function is used rather than // command to avoid the wrap-arounds and end-of-file messages. 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 = '^\\\(part\|chapter\|\(sub\)*section\|paragraph\)\>\|\%$\|\%^' let flags = 'W' . a:dir while i < a:cnt && search( pat, flags ) > 0 let i = i+1 endwhile let @/ = pat endfunction