【问题标题】:How can I apply vimrc conf file in .py如何在 .py 中应用 vimrc conf 文件
【发布时间】:2017-08-01 19:57:17
【问题描述】:

当我跑步时

vim good.html

:verbose set et?
  expandtab
        Last set from ~/.vimrc

但是当我跑步时

vim good.py

:verbose set et?
 expandtab
        Last set from /usr/share/vim/vim74/ftplugin/python.vim

我想在.py 中应用~/.vimrc 文件,而不是python.vim

昨天我一切都很好,但今天突然改变了路径

请有人教我如何改变路径

【问题讨论】:

    标签: vim


    【解决方案1】:

    把这个放到你的.vimrc:

    autocmd VimEnter *.py set expandtab
    

    或者如果您希望在加载所有插件后执行 .vimrc 的配置 - 以防它们更改了某些设置 - 您可以添加以下行:

    autocmd VimEnter * source ~/.vimrc
    

    注意:它可能会产生副作用,具体取决于您的 .vimrc 的内容,因为后者实际上会执行两次(在 vim 启动的开始和结束时) ) 所以你需要考虑这一点。

    现在关于插件,如果它们登录在某些特定文件夹中,例如 .vim 或 vim 安装路径,它们将自动加载,除非您将它们删除或运行某些特定命令以被忽略。

    Vim has also the ability to detect the type of file which is being edited, and this occurs when the option filetype is activated and probably this is what happened to you.

    所以输入:filetype 将确认这一点。如果您愿意,也许您可​​以为某些特定文件停用它。这取决于你!


    :help VimEnter

                                                       VimEnter
    
    VimEnter                        After doing all the startup stuff, including
                                    loading .vimrc files, executing the "-c cmd" 
                                    arguments, creating all windows and loading
                                    the buffers in them.
    

    【讨论】:

    • 感谢您的建议,我尝试autocmd VimEnter * source ~/.vimrc 并重新启动:so % 所以vim .py :verbose set et? 告诉我Last set from ~/.vimrc 但vim 仍然使用制表符而不是空格键=4 (ㅠ .ㅠ) ...在.pyfiletype detection:ON plugin:ON indent:ON
    • 我想我应该停用python.vim 或删除它但是当我运行sudo rm python.vim sudo 没有权限请问我该如何删除python.vim
    • 检查这个link。要知道它是制表符还是空格,请运行:set list,如果您仍然看到^I,那么您是对的。
    • 我错了@Meninx 我眼里没有^I 非常感谢!你解决了我的问题,非常感谢!!
    猜你喜欢
    • 2013-02-24
    • 2012-06-18
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多