Last active
September 12, 2015 14:19
-
-
Save scajanus/04ed683d40f204155bf6 to your computer and use it in GitHub Desktop.
GetTexEnv.vim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function! GetTexEnv() | |
| let s:env = substitute(getline('.'), '^\s*\\begin{\ze', '', '') | |
| return "}\<CR>\<CR>\\end{" . s:env . "}\<Up>" | |
| endfunction | |
| inoremap <expr> } getline('.') =~ '^\s*\\begin{[^}]\+' ? GetTexEnv() : '}' |
I'd go with '^.*\\begin{\ze\w\+\%#' to anchor the match to the cursor.
Edited the pattern to match everything before the cursor.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
'^\s*\\begin{\ze', '', '')part looks wrong as\beginis not always on a new line