VIM 7 和 cscope:使用“cscope find f”在键盘映射内用于在文件之间切换
我通常通过使用“我试图定义一个键盘快捷键”来在我的 cscope 索引代码库上的文件之间跳转,
:cscope find f <filename>
以防止我每次都必须键入“:cscope find f”。按此快捷键将弹出一个输入提示,我将在其中输入 cscope 数据库中文件名的一部分。如果有多个文件,它会显示文件列表,我可以从中选择我想要转到的文件。到目前为止我已经做到了这么多,但由于我根本不精通 VIM 脚本,所以我无法完成它。 (到目前为止,我编写的代码取自另一个问题,感谢 Eelvex)。
有人可以帮我纠正下面的脚本吗? 当我尝试使用此快捷方式时遇到许多错误
function! GetPat()
call inputsave()
let filename = input("Enter filename: ")
call inputrestore()
return filename
endfunction
map ` :cscope find f '.GetPat().'<CR>
I usually hop between files on my cscope-indexed codebase by using
:cscope find f <filename>
I'm trying to define a keyboard shortcut to prevent me having to type ":cscope find f" everytime. Pressing this shortcut would bring up an input prompt, to which I'll enter part of a filename in the cscope database. If there are multiple files, it would show up the list of files, from which I can select the file I want to go to. I've got to this much so far, but since I'm not at all proficient with VIM scripting, I'm unable to complete it. (what I've coded so far is taken from another question, thanks to Eelvex) .
Could someone correct the below script for me ?
I'm getting numerous errors while I try to use this shortcut
function! GetPat()
call inputsave()
let filename = input("Enter filename: ")
call inputrestore()
return filename
endfunction
map ` :cscope find f '.GetPat().'<CR>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
映射不会等待您输入内容然后继续。另外,映射是错误的,请记住映射的工作方式就像您键入文本一样,您可能会使用(未测试)进行类似的操作:
但为什么不只是:
这会让您在最后一个空格之后准备好输入模式然后点击输入。
The mapping won't wait for you to enter the input and then continue. Also, the mapping is wrong, remember that mappings work as if you typed the text, you might get away with something like that using (not tested):
But why not just:
That would leave you after the last space ready to enter your pattern and just hit enter.