简体   繁体   English

GVim视觉模式中的奇怪角色

[英]Weird characters in GVim's visual mode

When I enter visual mode (from normal mode), and when then I press : there are these characters: <,'> after the : 当我进入视觉模式(从正常模式),然后我按下:有这些字符: <,'>:

They are a feature or a bug? 它们是一个功能还是一个bug?

Windows XP SP2 Windows XP SP2

alt text http://img94.imageshack.us/img94/5590/16595366.jpg 替代文字http://img94.imageshack.us/img94/5590/16595366.jpg

您选择了可视范围,当您输入:在这种情况下,则会自动添加所选范围说明符'<,'>以指示该命令仅应用于选择。

In vi[m], you can apply : commands (ex-commands) on the current line (default), or any other line, or more generally, a range of lines. 在vi [m]中,您可以在当前行(默认)或任何其他行(或更一般地,一系列行)上应用:命令(ex-commands)。 The range is denoted as start,end . 范围表示为start,end For example, do delete the current line, you can do: 例如,删除当前行,你可以这样做:

:d

To delete three lines in the range (current-1) to (current+1): 要删除范围(current-1)到(current + 1)中的三行:

:-1,+1d

In vim , marks < and > are used to denote the current selection (or the last selection if nothing is selected). vim中 ,标记<>用于表示当前选择(如果未选择任何内容,则使用最后一个选择)。 So, when you type a : in visual mode, vim is smart enough to realize that you might want to apply the command only to the selected region, so gives you the range after the : . 因此,当您在可视模式下键入:时,vim足够聪明,可以意识到您可能只想将命令应用于所选区域,因此为您提供了以下范围之后的范围: You just type your command and the results apply only to the selection. 您只需键入命令,结果仅适用于选择。 (Well, the range defined by lines in the selection, to be precise.) (确切地说,选择中的行定义的范围。)

That means that you can actually move to the lines containing the beginning and the end of the last selected region by typing '< and '> respectively. 这意味着您可以通过分别键入“<”>来实际移动到包含最后一个选定区域的开头和结尾的行。 Replace ' with ` (backtick) to the beginning/end of the selection. ' with` (反引号)替换为选择的开头/结尾。

This is of course not a bug. 这当然不是一个错误。 It is the range modifier that can precede commands, in this case it means the visually highlighted range. 它是可以在命令之前的范围修饰符,在这种情况下,它表示视觉上突出显示的范围。

Type 类型

:h cmdline-ranges

to learn more about ranges. 了解范围的更多信息。

它们是范围的正常指示。

'<,'> is your visually selected area. '<,'>是您在视觉上选择的区域。 Think about it, its easy to represent ranges if you know numbers, but for a visually selected text the only way to represent them (write/type it down) would be to use specialized symbols, and in this case '<,'> 想一想,如果你知道数字,它很容易表示范围,但对于视觉选择的文本,表示它们的唯一方法(写/键入它)将使用专门的符号,在这种情况下'<,'>

What more, you can do commands on the visually selected area the same way you'd do commands over a range of line numbers 此外,您可以在视觉选择区域执行命令,就像在一系列行号上执行命令一样

1,200 s/old/new/c

'<,'> s/old/new/c

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

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