Vim: % 命令没有移动到第一个括号
Vim: % command doesn't move to first parenthesis
我正在阅读 vim 手册。我使用 % 命令得到了意外的结果。
这是手册中的引述:
When the cursor is not on a useful character, "%" will search forward to find
one. Thus if the cursor is at the start of the line of the previous example,
"%" will search forward and find the first "(". Then it moves to its match:
if (a == (b * c) / d)
---+---------------->
%
但是,当我重复同样的操作(将光标放在行首)并按 % 时,光标会移动最后一个 )
括号。
我没有配置 vim,我使用的是默认设置。我在想是不是我的vim没有配置好。有没有办法配置 vim 使其将光标移动到第一个括号,类似于手册中的描述?
我在 Windows 上使用 gVim。
"it moves to its match",这意味着它将移动到它找到的匹配括号(在本例中为右括号)。所以它做了它应该做的。
要返回第一个括号,您需要再次按“%”!
您也可以使用f(
将光标移动到第一个左括号(如果不在同一行,您可以像/(
一样轻松地搜索它)。这很有用,因为您可以执行类似 df(
(或 d/(
以定位不同的行)之类的操作来删除直到并包括左括号的所有内容。而依靠双按 %
是不允许的。
我正在阅读 vim 手册。我使用 % 命令得到了意外的结果。
这是手册中的引述:
When the cursor is not on a useful character, "%" will search forward to find one. Thus if the cursor is at the start of the line of the previous example, "%" will search forward and find the first "(". Then it moves to its match:
if (a == (b * c) / d) ---+----------------> %
但是,当我重复同样的操作(将光标放在行首)并按 % 时,光标会移动最后一个 )
括号。
我没有配置 vim,我使用的是默认设置。我在想是不是我的vim没有配置好。有没有办法配置 vim 使其将光标移动到第一个括号,类似于手册中的描述?
我在 Windows 上使用 gVim。
"it moves to its match",这意味着它将移动到它找到的匹配括号(在本例中为右括号)。所以它做了它应该做的。
要返回第一个括号,您需要再次按“%”!
您也可以使用f(
将光标移动到第一个左括号(如果不在同一行,您可以像/(
一样轻松地搜索它)。这很有用,因为您可以执行类似 df(
(或 d/(
以定位不同的行)之类的操作来删除直到并包括左括号的所有内容。而依靠双按 %
是不允许的。