[英]Command to move cursor to matched pattern in vim
I know /dog<CR>
will place my cursor at the first instance of dog
, however I'm not getting the same effect when using a command. 我知道/dog<CR>
会将光标放在dog
的第一个实例上,但是使用命令时效果不一样。
I've tried the following: 我尝试了以下方法:
:command FindDog /dog
:command FindDog exec '/dog'
:command FindDog :normal /dog<CR>
(this one seems to just hang until I Ctrl-C) :command FindDog :normal /dog<CR>
(这似乎一直挂着,直到我按Ctrl-C为止)
Something tells me I'm doing this wrong. 某事告诉我我做错了。
Perhaps you want to know that, :/dog<cr>
works too. 也许您想知道, :/dog<cr>
也可以。 It does the same as /dog
. 它和/dog
。 You don't have to call the search()
function. 您不必调用search()
函数。 If you would like to create your own command, you can just do for example: 如果您想创建自己的命令,则可以例如执行以下操作:
:command FindDog :/dog
Ugh. 啊。 call search('dog')
did the trick. call search('dog')
达到了目的。 I will let someone with more than a week of vim decide if this question would help anyone else or not. 我将让vim超过一周的人决定这个问题是否对其他人有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.