开发者

Removing a line from the buffer in a vim script

开发者 https://www.devze.com 2022-12-24 04:01 出处:网络
According to http://vimdoc.sourceforge.net/htmldoc/usr_41.html#function-list vim script has functions setline() and append() to modify the current buffer but how do i delete a line from within a scrip

According to http://vimdoc.sourceforge.net/htmldoc/usr_41.html#function-list vim script has functions setline() and append() to modify the current buffer but how do i delete a line from within a script? With setline(1, "") the line is only emptied but I want to get r开发者_StackOverflow中文版id of it.


You use the ex command :d. :5d deletes line 5.


One addition: don’t do execute line 'delete', do execute line 'delete _': deleting to black hole register has a minimal number of side-effects. Without _ it will delete to default register, numbered register 1 and will move all other numbered registers (except 0 which is for yanks): 1->2, 2->3, …, 9->void.


@ahe
1delete
%delete
1,$delete

no need for execute here

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号