在 Vim 可视模式下,为什么命令以 '<,'> 开头?
例如,当我进入 Vim 的可视模式以缩进一段文本时,命令提示符始终以 '<,'>
开头。有人可以帮我解释一下为什么会这样或者更确切地说它是做什么的吗?看起来它与标记有关,但根据我迄今为止阅读的手册内容,我并不完全确定这一点。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
'<
是视觉选择的第一行,'>
是视觉选择的最后一行。这是 vim 使命令仅应用于可视区域的方式。'<
is the first line visually selected, and'>
is the last line visually selected. This is vim's way of making your command apply to only the visual area.命令行开头的
'<,'>
代表您选择的范围。这也是您要输入的命令将应用的测试范围。例如,如果我在可视模式下选择了文本区域,然后想要用“溢出”替换所有出现的“堆栈”,我的命令将如下所示:
如果没有可视模式,则必须通过指定行范围来完成相同的命令手例如:
The
'<,'>
at the beginning of your command line represents the range which you have selected . This is the also the range of test onto which the command you are about to enter would be applied.For example if I selected a region of text in visual mode and then wanted to replace all occurrences of 'stack' with 'overflow' my command would look like:
Without visual mode this same command would have to be accomplished by specifying the line range by hand eg:
它是由两个特殊标记定义的范围(名为“quote+1 letter”的文本中锚点中的标记)
来源
It's a range defined by two special marks (a mark in an anchor in the text named as "quote+1 letter")
Source
一旦您在可视模式下选择了五行,那么
'<,'>
意味着您将在该区域执行该命令。因此
:'<,'>s/replaceMe/WithThis/g
将仅应用于该选择Once you select in Visual Mode e.g. five lines, then
'<,'>
means that you will execute the command in that region.so
:'<,'>s/replaceMe/WithThis/g
will apply to only that selection花时间在已经给出的答案中添加一些琐事
:*
通常意味着相同的 (:he cpo-star
),在命令行模式下点击
Cu
会删除范围标记(实际上, 首)Taking the time to add some points of trivia to the already given answers
:*
usually means the same (:he cpo-star
),hitting
C-u
in command line mode removes the range marker (actually, removes to the beginning of the line)