This has already been requested in the past, see https://github.com/vim/vim/issues/5632.
On 2022-03-29, Ernie Rael wrote: > I've done little vim9script programing (and no vimscript). > > I want to replace a part of a buffer line. I thought to do "getline()", > slicing, "setline()", no joy; I couldn't see any way to manipulate the > string directly.Anything better I couldn't find? I'm still getting used > to the synthesis of vim9script and vim commands > > In the following, F1() seems expensive, F2() feels uncomfortable (for > example 'x' command might go to the next line). For performance is F2() > better (assuming there's some checking). > > Any comments/suggestions appreciated > > -ernie > > vim9script > # This line gets modified > # This line gets modified > > def F1(lino: number, pos1: number, pos2: number, newtext: string) > var t1 = getline(lino)->str2list() > t1->remove(pos1, pos2) > t1->extend(str2list(newtext), pos1)->list2str()->setline(lino) > > enddef > > def F2(lino: number, pos1: number, pos2: number, newtext: string) > cursor(lino, pos1 + 1) > execute 'normal ' .. (pos2 - pos1 + 1) .. 'x' > execute 'normal i' .. newtext > enddef > > F1(2, 12, 15, 'BOO') > F2(3, 12, 15, 'FOO') > > > -- > -- > You received this message from the "vim_dev" maillist. > Do not top-post! Type your reply below the text you are replying to. > For more information, visit http://www.vim.org/maillist.php > > --- > You received this message because you are subscribed to the Google Groups > "vim_dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/vim_dev/773e9647-93d1-b339-18f6-783e3316e484%40raelity.com. -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/YkTPjQ62DT6VC/u9%40laptop.homenetwork.
