Closed notuxic closed 2 years ago
I can not merge this pr for now because of breaking dot-repetability.
I'll look into it. But I don't have a lot of free time on my hands right now, so it may take a while until I get to it.
I finally merge it (rebase and resolve conflicts). See 7cc8f7390a1239e684af72b12ce2ce22fab3a3dd Thank you for your contribution.
I have changed the key and feature, use "with_submatch" instead of "input_after_with" so that both "input" and "input_after" can be used as replace pattern.
For now, you can use
"" add endwise rule for LaTeX environments
call lexima#add_rule({
\ 'filetype': 'tex',
\ 'char': '<CR>',
\ 'input': '<CR>',
\ 'input_after': '<CR>\\end{\1}',
\ 'at': '^.*\\begin{\([^}]*\)}\(\[.*\]\)*\%#$',
\ 'with_submatch': 1,
\ })
This PR adds an additional rule key "input_after_with" which can use backreferences to capture groups in the key "at".
This allows creation of rules where the closing string requires a substring of the opening string, such as in HTML tags or LaTeX environments.
Example usage for LaTeX: