如果我在函数名称上使用gd来执行以下操作:
def function_name(parameter1, parameter2):
...
...
vim搜索“function_name(parameter1”但我希望它只搜索“function_name”。 我怎么能这样做?
答案 0 :(得分:2)
Vim的gd
实际上不是“搜索”功能,而是转到(因此是g
),在本例中是本地声明。有几种方法可以尝试搜索function_name,最简单的方法可能是*
,它会在其光标下搜索一个单词。 n
将以“向前”的方向引导您完成每一项,而#
只会向后“向后”。
答案 1 :(得分:1)
听起来您的问题是iskeyword
包含(
字符。
*
/ #
将使用iskeyword
确定光标下的完整 word 。就我而言,如果我有以下文件:
function foobar_name(params) {
}
call function_name(param1);
^-- Cursor is here
如果按 * ,则Vim将执行:/\<function_name\><Cr>
。
我的iskeyword
看起来像这样:iskeyword=@,48-57,_,192-255
来自the docs:
*'iskeyword'* *'isk'*
'iskeyword' 'isk' string (Vim default for MS-DOS and Win32:
"@,48-57,_,128-167,224-235"
otherwise: "@,48-57,_,192-255"
Vi default: "@,48-57,_")
local to buffer
{not in Vi}
Keywords are used in searching and recognizing with many commands:
"w", "*", "[i", etc. It is also used for "\k" in a |pattern|. See
'isfname' for a description of the format of this option. For C
programs you could use "a-z,A-Z,48-57,_,.,-,>".
For a help file it is set to all non-blank printable characters except
'*', '"'' and '|' (so that CTRL-] on a command finds the help for that
command).
When the 'lisp' option is on the '-' character is always included.
NOTE: This option is set to the Vi default value when 'compatible' is
set and to the Vim default value when 'compatible' is reset.