如何拉扯相对线?

时间:2016-11-17 11:20:41

标签: vim

我已打开相对行号。

我可以使用:10y轻击第10行。

但是如何我说下当前一行以下的第5行而没有跳到所说的行,然后跳回来(即5jY5k)。

如果我有这个档案:

2   describe 'foobar' do
1     it 'should be cool' do
46      # do stuff
1     end
2  end

我在第46行,我想要在相对的第1或第2行上下拉动。

1 个答案:

答案 0 :(得分:9)

您可以将+n-n用于相对地址:

:+2y    " Two lines after the current line
:-2y    " Two lines before the current line

你也可以把它结合起来:

:-2,+2y   "  Two lines before the cursor and two lines after

另请参阅this answer了解更多示例,并参阅:help [range]了解Vim文档。

相关问题