-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make (all) surrounding delimiters large #2313
Comments
Interesting suggestion. It should be possible. Let me play with it and see what I can do. |
I've added a function now. You can test it by calling it directly or mapping it, e.g.: nnoremap <f8> :<c-u>call vimtex#delim#toggle_modifier_all()<cr> I may make a mapping or command interface for this, but it would be useful with some feedback first. And perhaps a suggestion of default map and/or command name. |
Right now this is going into an infinite loop when I apply it in |
Sorry, that should be fixed now. |
Awesome, this is going into my snippets file right away. Two remarks:
The latter can be avoided by the following patch diff --git a/autoload/vimtex/delim.vim b/autoload/vimtex/delim.vim
index 56e4702..5778f16 100644
--- a/autoload/vimtex/delim.vim
+++ b/autoload/vimtex/delim.vim
@@ -124,7 +124,6 @@ endfunction
" }}}1
function! vimtex#delim#toggle_modifier_all() abort " {{{1
- call vimtex#util#undostore()
" Use syntax highlights to detect region math region
let l:ww = &whichwrap
@@ -139,6 +138,7 @@ function! vimtex#delim#toggle_modifier_all() abort " {{{1
call vimtex#pos#set_cursor(l:cursor)
+ let l:undostore = v:false
while v:true
let [l:open, l:close] = vimtex#delim#get_surrounding('delim_modq_math')
if empty(l:open) || vimtex#pos#val(l:open) <= l:startval
@@ -148,6 +148,11 @@ function! vimtex#delim#toggle_modifier_all() abort " {{{1
call vimtex#pos#set_cursor(vimtex#pos#prev(l:open))
if !empty(l:open.mod) | continue | endif
+ if !l:undostore
+ call vimtex#util#undostore()
+ let l:undostore = v:true
+ endif
+
" Add close modifier
let line = getline(l:close.lnum)
let line = strpart(line, 0, l:close.cnum - 1) |
Agreed. Do you have a suggestion? How about
Thanks, fixed now. |
I've implemented this fully now, but please, feel free to comment the naming and default map. I don't mind changing it if you have a better idea. |
Is your feature request related to a problem? Please describe it.
Using
\left
and\right
can be a bit of a chore. Especially if you start writing a formula with lots of delimiters and only notice halfway in that there is a "tall" expression in there.Describe the solution you'd like
It would be quite helpful to have a function (and probably also a normal mode mapping) that finds all math delimiters surrounding the cursor and makes them
\left
/\right
delimiters if they are not already. E.g.(
|
is supposed to be the cursor position) would becomeThe use case I have in mind is binding this to some key combination in insert mode which I could press after writing a fraction/sum/integral so that I don't have to worry about manual
\left
/\right
again. Even better, I could integrate this into my snippets to make it 100% automatic.Describe alternatives you've considered$tsd$ but this will only change the innermost delimiter. It's also a toggle so I can't just have my snippets call it automatically.
Currently I can do
The text was updated successfully, but these errors were encountered: