Vim 拉取行范围 [英] Vim yanking range of lines
问题描述
我是一名 C# 开发人员,最近决定扩展我对可用工具的了解.我决定学习的第一个工具是 Vi/Vim.到目前为止一切进展顺利,但有几个问题我似乎无法找到答案:
I'm a C# developer who has just recently decided to expand my knowledge of the tools available to me. The first tool I've decided to learn is Vi/Vim. Everything has been going well so far, but there are a couple of questions I can't seem to find the answer to:
假设我想拉出一系列行.我知道有很多方法可以这样做,但我想按行号来做.我认为它类似于替代命令的工作方式,例如
81,91y
.有没有办法做到这一点?
Lets say I wanted to yank a range of lines. I know there are many ways of doing so, but I would like to do it by line number. I figured it would be similar to how the substitute commands work, something like
81,91y
. Is there a way to do this?
我对正常模式下的 g
命令有点困惑.它似乎做了很多事情,我无法真正确定 g 命令的核心是什么.我对它是运动命令还是其他命令通过正常模式运行的一种全部捕获"感到困惑.有人可以解释一下吗,或者给我一个很好地解释 g
命令的参考资料?
I'm a little confused about the g
command in normal mode. It seems to do a myriad of things and I can't really determine what the g command does at its core. I'm confused on whether or not it's a motion command or a kind of "catch all" for other commands ran through normal mode. Can someone please explain this or point me to a reference that gives a good explanation of the g
command?
推荐答案
Yank lines 81-91
Yank lines 81-91
:81,91y<enter>
如果您的手指不喜欢找到 :
和 ,
键,这也可以(转到第 81 行,拉出 11 行)
If your fingers don't like to find the :
and ,
keys, this would work as well (go to line 81, yank 11 lines)
81gg11yy
我唯一使用 g
是 5gg
.去5号线.22gg
:第 22 行.正如jimbo所说,它实际上只是其他一些命令的修饰符.
My only use of g
is 5gg
. To go to the 5th line. 22gg
: 22nd line. As jimbo said, it's really only a modifier for some other commands.
为了完整起见,(http://vim.wikia.com/wiki/Power_of_g)解释了很多 g
在命令模式下的工作原理.
For completeness, (http://vim.wikia.com/wiki/Power_of_g) explains a lot of how g
works in command mode.
这篇关于Vim 拉取行范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!