我认为问题出在 Vim 处理函数的方式上。从文档中[[:
*[[*
[[ [count] sections backward or to the previous '{' in
the first column. |exclusive|
Note that |exclusive-linewise| often applies.
Run Code Online (Sandbox Code Playgroud)
除非在某个地方专门为 python 文件定义了一个部分(我不相信这是可能的,因为它们应该是两个字母的 nroff 部分),否则这将假设第一列中应该有一个开括号,这与 python 文件无关。
我建议在 Vim 邮件列表上询问是否有任何插件或解决方法。或者,您可以定义如下映射:
nmap gd :let varname = '\<<C-R><C-W>\>'<CR>?\<def\><CR>/<C-R>=varname<CR><CR>
Run Code Online (Sandbox Code Playgroud)
这可以通过函数更优雅地完成,但这只是一个应该可行的快速技巧。它映射gd到一个函数,该函数设置变量“varname”来保存光标所在的单词,向后搜索 def,然后向前搜索该变量:
:let varname = " Variable setting
'\< " String start and word boundary
<C-R><C-W> " Ctrl-R, Ctrl-W: pull in the word under the cursor
\>' " Word boundary and string end
<CR> " Enter - finish this command
? " Search backwards for...
\<def\> " def but not undefined etc (using word boundaries)
<CR> " Enter - Perform search
/ " Now search forward
<C-R>= " Pull in something from an expression
varname<CR> " The expression is 'varname', so pull in the contents of varname
<CR> " Enter - perform search
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1243 次 |
| 最近记录: |