为什么我在安装 vundle 后无法获取我的 vimrc? [英] Why can't I source my vimrc after installing vundle?

查看:30
本文介绍了为什么我在安装 vundle 后无法获取我的 vimrc?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在编辑 vimrc 后让我的 Vim 即时更新.所以我按照 Vimcast 的说明操作每次点击保存时都使用 vimrc.

I'm trying to get my Vim to update on the fly after editing vimrc. So I followed the instructions at Vimcast which basically source vimrc every time you hit save.

但是由于某种原因这不起作用(当我保存我的 vimrc 时它不会给出任何错误),所以我决定手动运行 source $HOME/.vimrc,这就是我的得到:

But that doesn't work for some reason (when I save my vimrc it doesn't give any errors), so I decided to run source $HOME/.vimrc manually and here's what I got:

    -bash:  Configuration file for vim
            set nocompatible                              : command not found
    -bash:  Plugin Management {
            filetype off                                  : command not found
    -bash: .vimrc: line 7: syntax error near unexpected token `('
    -bash: .vimrc: line 7: `        call vundle#rc()'

这是我的 Vim 信息(我运行的是 Mac OS X 10.7.3):

And here's my Vim info (I'm running Mac OS X 10.7.3):

    VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jul 31 2011 19:27:29)
    Compiled by root@apple.com
    Normal version without GUI.  Features included (+) or not (-):
    -arabic +autocmd -balloon_eval -browse +builtin_terms +byte_offset +cindent 
    -clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments 
    -conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs 
    -dnd -ebcdic -emacs_tags +eval +ex_extra +extra_search -farsi +file_in_path 
    +find_in_path +float +folding -footer +fork() -gettext -hangul_input +iconv 
    +insert_expand +jumplist -keymap -langmap +libcall +linebreak +lispindent 
    +listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape 
    -mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm -mouse_sysmouse 
    +mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg -osfiletype 
    +path_extra -perl +persistent_undo +postscript +printer -profile -python 
    -python3 +quickfix +reltime -rightleft -ruby +scrollbind +signs +smartindent 
    -sniff +startuptime +statusline -sun_workshop +syntax +tag_binary 
    +tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
    -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo 
    +vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
    -xterm_clipboard -xterm_save 
    system vimrc file: "$VIM/vimrc"
    user vimrc file: "$HOME/.vimrc"
    user exrc file: "$HOME/.exrc"
    fall-back for $VIM: "/usr/share/vim"
    Compilation: gcc -c -I. -D_FORTIFY_SOURCE=0 -Iproto -DHAVE_CONFIG_H -arch i386 -arch x86_64 -g -Os -pipe
    Linking: gcc -arch i386 -arch x86_64 -o vim -lncurses

有人可以帮我吗?非常感谢!

Could anybody give me a hand here? Thanks so much!

== 更新 ==

正如你们所有人所指出的,我混淆了 Vim 源代码和 Bash 源代码命令 - 谢谢.

So as all of you have pointed out, I mixed up the Vim source and Bash source commands - Thanks.

现在我已经尝试在 Vim 中运行源代码并且它没有错误地工作.但是,它似乎仍然没有更新我的 vimrc.我的 vimrc 中有这一行

Now I've tried running source within Vim and it worked without errors. However, it still doesn't seem to update my vimrc. I have this line in my vimrc

    nnoremap <leader><TAB> :sp ~/.vimrc<CR>

无论我是否注释掉该行,在运行 source ~/.vimrc 后点击 仍然会在分割中打开我的 vimrc屏幕.

No matter whether I comment out the line, hitting <leader><TAB> after running source ~/.vimrc still opens up my vimrc in a split screen.

推荐答案

那是 :source ...,在 Vim 中执行.从您的输出来看,您似乎错误地在 Bash shell 中执行了它(可能通过 :!source);source 也是一个 Bash 内置命令(如 .),用于将文件内容作为 Bash 命令执行.

That's :source ..., executed from within Vim. From your output, it appears that you have mistakenly executed it in the Bash shell itself (maybe via :!source); source also is a Bash built-in command (like .) to execute the file contents as Bash commands.

要调试对您不起作用的:autocmd,您可以临时添加

To debug the :autocmd that's not working for you, you could temporarily add

:echomsg "executing .vimrc"

或使用 :15verbose write 编写 .vimrc 以查看发生了什么.

or write the .vimrc with :15verbose write to see what's going on.

这篇关于为什么我在安装 vundle 后无法获取我的 vimrc?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆