【问题标题】:Restrict vim auto completion to search current file only?限制vim自动完成仅搜索当前文件?
【发布时间】:2014-07-10 23:17:31
【问题描述】:

ctrl+nctrl+p 对于 Vim 来说是非常方便的补全,但有时会很慢,这可能是由于当前源中包含的头文件太多。是否有限制自动完成仅搜索当前源文件(或打开的流)的选项?

【问题讨论】:

    标签: vim


    【解决方案1】:

    您必须使用complete 选项。

    从帮助文件中,

    The default is ".,w,b,u,t,i", which means to scan:
       1. the current buffer
       2. buffers in other windows
       3. other loaded buffers
       4. unloaded buffers
       5. tags
       6. included files
    

    就我个人而言,我注意到删除包含的文件确实很有帮助,因此,在我的 .vimrc 中,我使用:

    set complete-=i
    

    但您也可以删除(或添加)其他列表。

    更多信息请参见:help 'complete'

    【讨论】:

      【解决方案2】:

      如果您对“有时”是什么时候有感觉(大型项目,包含许多包含的复杂 C 文件,...),您还可以使用 <C-x><C-n> 本地文件完成,请参阅 :help i_CTRL-X_CTRL-N。这样一来,您仍然可以使用默认补全功能,而无需弄乱'complete' 选项。

      【讨论】:

      • 伟大而灵活的解决方案。谢谢。
      【解决方案3】:

      :help i_ctrl-n 说:

      Find next match for words that start with the
      keyword in front of the cursor, looking in places
      specified with the 'complete' option. The found
      keyword is inserted in front of the cursor.
      

      下一步是相当明显的,不是吗?

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-01-24
        • 2012-03-20
        • 1970-01-01
        • 2014-12-28
        相关资源
        最近更新 更多