简体   繁体   中英

vim: yank lines above the current line together with the current line

I find myself doing Nyy very often to yank the current line and N-1 lines below. So 3yy would yank the current line and 2 more lines (so all together 3).

I know how to yank N lines above the current line ( yNk ), but this does not include the current line. What I want is to yank the current line and N-1 lines above. How do I do this (ideally also with the yy command)?

Edit: Apparently yNk includes the current line as well. I must have missed it. Thx for the comments.

The following will yank the current line plus two above:

2yk

Obviously changing the 2 will alter the number of lines yanked above. No number is an implicit 1 , so yk is equivalent to 1yk .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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