[英]What is the definition of a non-blank character in Vim?
Launch vim. 启动vim。 In the empty buffer, insert two lines where the first line consists of 3 spaces and the second line consists of hello world
. 在空缓冲区中,插入两行,其中第一行包含3个空格,第二行包含hello world
。
Here is an example file where the spaces are represented with dots. 这是一个示例文件,其中空格用点表示。
...
hello world
Now press gg
. 现在按gg
。 The cursor moves to the third space of the first line. 光标移动到第一行的第三个空格。
Quoting :help gg
: 引用:help gg
:
<C-Home> or *gg* *<C-Home>*
gg Goto line [count], default first line, on the first
non-blank character |linewise|. If 'startofline' not
set, keep the same column.
The documentation says that the cursor should move to the first non-blank character of the first line. 文档说光标应该移动到第一行的第一个非空白字符。 I have two questions. 我有两个问题。
:help
document the definition of a non-blank character? :help
记录非空白字符的定义吗? If so, could you please point me to it? 如果是这样,你能指点我吗? :help gg
? 我们在上述实验中观察到的行为是否与提供的文档一致:help gg
? I don't think there is a general definition of non-blank in the vim docs, but I also do not believe this is a "side effect" of gg
. 我不认为vim docs中有非空白的一般定义,但我也不相信这是gg
的“副作用”。
Note that gg
is consistent here with ^
: 请注意, gg
与^
一致:
^ To the first non-blank character of the line.
|exclusive| motion.
and [:blank:]
of vim's pattern matching behavior ( :h blank
) defines blank characters as space and tab: 和vim的模式匹配行为的[:blank:]
( :h blank
)将空白字符定义为空格和制表符:
*[:blank:]* [:blank:] space and tab characters
As far as whether or not this is consistent with gg
, consider what it says it will do as two steps instead of one: 至于这是否与gg
一致,请考虑它所说的将作为两个步骤而不是一个步骤:
Probably the easiest way to implement 2 as an algorithm is to position the cursor after all the blank characters at the beginning of the line . 将2作为算法实现2的最简单方法可能是将光标定位在行开头的所有空白字符之后 。 In your case, they are all blank characters (and it cannot move to the next line), so the cursor is positioned at the end of the line (after all the blank characters). 在您的情况下,它们都是空白字符(并且它不能移动到下一行),因此光标位于行的末尾(在所有空白字符之后)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.