防止vim意外打开二进制文件?
当我打算打开关联的源代码“foo.cpp”时,我经常意外地打开二进制可执行文件,即“foo”。问题的根源在于制表符补全,即 :e fo
通常出现在二进制文件而不是源代码上。
有没有办法让 vim 只显示文本文件的完整名称?或者,更改选项卡完成顺序?
有时我的仓促制表符完成错误发生在 vim 之外;对于这些情况,阻止 vim 打开非文本文件的最佳方法是什么?
I frequently accidentally open a binary executable, i.e. "foo", when I mean to open the associated source code "foo.cpp". The root of the problem is that tab completion, i.e. :e fo<tab>
typically lands on the binary instead of the source code.
Is there a way to get vim to only tab complete names of text files? Or alternatively, change the tab completion order?
Sometimes my hasty tab completion error happens outside of vim; for those cases, what is the best way to prevent vim from opening files that are not text?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不完全是你需要的,但我的 .vimrc 中有类似的东西
Not exactly what you need, but I have something like this in my .vimrc
对于 vim 之外的制表符补全,这取决于您的 shell。大多数 shell 都有某种形式的自动完成支持。特别是,Zsh 能够自动完成例如 ssh 的远程主机。我不是这些方面的向导,但是当您键入的命令以“vim”开头时,让您的 shell 从自动完成列表中删除具有某些后缀的文件可能相对简单。
快速谷歌搜索会出现此页面,其中包含以下内容:
修改此逻辑应该不会太困难得到你想要的(如果你使用 Zsh)。
For tab completion outside of vim, that will depend on your shell. Most shells have some form of autocompletion support. In particular, Zsh has the ability to autocomplete e.g. remote hosts for ssh. I'm not a wizard with these things, but it would probably be relatively simple to get your shell to drop files with certain suffixes from the autocompletion list when the command you are typing starts with "vim".
A quick google search turn up this page, which has this:
It should not be too difficult to modify this logic to get what you want (if you use Zsh).
也许您会发现这很有用:(
取自 如何让 vim 对文件名执行正常(类似 bash)制表符补全?)
Maybe you can find this useful:
(taken and using from How do I make vim do normal (bash like) tab completion for file names?)