Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- " latex $text-objects$
- function! s:ADollar()
- if search('\m\%#\$', 'bcnW')
- " On $
- if search('\m\_.\+\$', 'nW')
- return "/\\$\<CR>"
- elseif search('\m\$\_.\+\%#', 'bnW')
- return "?\\$\<CR>"
- else
- return "\<C-\>\<C-n>\<Esc>"
- endif
- elseif search('\m\$\%(\%(\$\)\@!\_.\)*\%#\_.\{-}\%(\$\)', 'bcnW')
- " Between $ and $
- return "?\\$\<CR>o/\\$\<CR>"
- endif
- " Return to normal mode and sound a bell.
- return "\<C-\>\<C-n>\<Esc>"
- endfunction
- function! s:IDollar()
- let vad = s:ADollar()
- if vad !~ '\m[\x1b]' " If the result contains an <Esc>, not in a dollar
- return vad . 'owoge'
- endif
- return vad
- endfunction
- vnoremap <expr> a$ <SID>ADollar()
- vnoremap <expr> i$ <SID>IDollar()
- onoremap a$ :normal va$<CR>
- onoremap i$ :normal vi$<CR>
Advertisement
Add Comment
Please, Sign In to add comment