On Fr, 27 Apr 2018, Bram Moolenaar wrote: > > here is a patch, that allows the setline() functions to remove lines > > after the newly added content. For example you have used setline() to > > add 10 lines to a buffer and later one, you noticed you only want the > > buffer to have 2 lines, you cannot do it without deleting the whole > > buffer using e.g. `:%d` before. > > > > While that is okay for using `setline()` it becomes cumbersome, if one > > needs to do it for the non-current buffer, e.g. using setbufline() it is > > not possible, without manually going to the buffer, deleting it and then > > using setline(). That means, one cannot take advantage of the > > `setbufline()` function at all and might not be possible for timer or > > async functions. > > > > So here is a patch, that allows to remove lines after the newly pasted > > content. > > Hmm, this is counterintuitive: A function that adds some lines and > deletes others. > > Another way would be to have a replace() function: > call replace(first, last, lines)
Well, setline() already does replace. > But probably it's better to just add a delete lines function, to counter > the setline() and setbufline() functions: > call delline(lnum) > call delline(first, last) > call delbufline(buffer, lnum) > call delbufline(buffer, first, last) > > Better than: > exe first . ',' . last . 'd' Hm, I am not convinced. Since setline() already basically works like replacing, it made sense to only add the last tiny bit to make it a true replace function. I mean, I can add two more functions but it seems not to add that much value. Best, Christian -- -- 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]. For more options, visit https://groups.google.com/d/optout.
