Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 0.86 KB | None | 0 0
  1. " vim-texaround: Small plugin for wrapping text in a LaTeX command or environment
  2.  
  3. function! TexWrapCommand(vt)
  4.     let c = input("")
  5.     if c ==# "\<Esc>" || c ==# "\<C-c>"
  6.         return
  7.     endif
  8.     if a:vt == 'line' || a:vt == 'V'
  9.         normal! '>A}
  10.        execute "normal! '<i\\".c."{"
  11.     else
  12.         normal! `>a}
  13.         execute "normal! `<i\\".c."{"
  14.     endif
  15.     echo "success"
  16. endfunction
  17.  
  18. function! TexWrapEnv(arg)
  19.     let c = input("")
  20.     if c ==# "\<Esc>" || c ==# "\<C-c>"
  21.         return
  22.     endif
  23.     execute "normal! '>o\\end{".c."}"
  24.     execute "normal! '<O\\begin{".c."}"
  25.     normal! ='>$F{
  26.    echo "success"
  27. endfunction
  28.  
  29. vnoremap \tc <ESC>:call TexWrapCommand(visualmode())
  30. vnoremap \te <ESC>:call TexWrapEnv(visualmode())
  31.  
  32. nnoremap \tc <ESC>:set opfunc=TexWrapCommand<CR>g@
  33. nnoremap \te <ESC>:set opfunc=TexWrapEnv<CR>g@
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement