开发者

Removing a line from the buffer in a vim script

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜