简体   繁体   English

如何拉扯相对线?

[英]How to yank relative line?

I have relative line numbers turned on. 我打开了相对的行号。

I can yank line 10 using :10y . 我可以使用:10y猛拉第10行。

But how to I yank say the 5th line below the current line without jumping to said line, yanking and jumping back (ie 5jY5k ). 但是如何我说下当前线下面的第5行没有跳到所述线, 5jY5k和跳回(即5jY5k )。

If I had this file: 如果我有这个文件:

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

I am on line 46 and I want to yank relative line 1 or 2, either above or below. 我在第46行,我想要在相对的第1或第2行,无论是上方还是下方。

You can use +n and -n for relative addresses: 您可以使用+n-n作为相对地址:

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

And you can also combine this: 你也可以结合这个:

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

Also see this answer for some more examples and :help [range] for the Vim documentation. 另请参阅此答案以获取更多示例和:help [range]获取Vim文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM