I repeatedly need to transform
word
into
\edlemvar{word}{}{}
or
\edlemvar{}{}{word}
More generally, it would be great to have a way to do this even if there are more words on the line than "word," something like <count>COMMANDSEQUENCE
where <count>
is however many words I would like to include in either pair of braces; the rest of the words on the line would then appear on a new line. That is, I'd like to convert (for <count> = 2
)
word1 word2 word3 word4
to
\edlemvar{word1 word2}{}{}
word3 word 4
or
\edlemvar{}{}{word1 word2}
word3 word 4
Question: Is there some clever way in Vim/Neovim to do either this general transformation with minimal keystrokes?
I use a custom snippet that turns edlv
into \edlemvar{}{}{}
. But then I still need to type Iedlv<tab><esc>$miwbp
to do the first operation, or Iedlv<tab><esc>$miwhP
for the second --- and that's just the simple case.
Note: I use cutlass/subversive/yoink. If you don't, please replace m
with d
.
<count>mawiedlv<tab><esc>p
or<count>mawiedlv<tab><tab><tab><esc>p
? This almost works, but often leaves extra white space within the braces."I use a custom snippet"
Care to share what snippet plugin you are using? AFAIK, most snippet engines support a visual placeholder, so thatv3iw<tab>edlv<tab>
results in\edlemvar{word1 word2}{}{}
ultisnips
. I tried your sequence just now and it didn't work (I just got\edlemvar{}{}{}
. Do I need to add something to the snippet to tell it where to put the portion selected in visual mode?$VISUAL
in your snippet. Let me post an answer to include the details