vim - 为什么安装 vundle 后无法获取 vimrc 源?

标签 vim

我试图让我的 Vim 在编辑 vimrc 后即时更新。所以我按照Vimcast的说明进行操作。基本上每次你点击保存时都会源 vimrc。

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

    -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):

    VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jul 31 2011 19:27:29)
    Compiled by <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="73011c1c07331203031f165d101c1e" rel="noreferrer noopener nofollow">[email protected]</a>
    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

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

==更新==

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

现在我尝试在 Vim 中运行源代码,它工作正常,没有错误。但是,它似乎仍然没有更新我的 vimrc。我的 vimrc 中有这一行

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

无论我是否注释掉该行,都会点击<leader><TAB>运行后source ~/.vimrc仍然在分屏中打开我的 vimrc 。

最佳答案

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

要调试不适合您的 :autocmd,您可以临时添加

:echomsg "executing .vimrc"

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

关于vim - 为什么安装 vundle 后无法获取 vimrc 源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13365129/

相关文章:

Vim:如果内容不同,则仅显示 “file has been changed” 警告

linux - 更改 Ctrl + w 的 Vim 键盘映射

linux - 如何使用 vi 在 Linux 的终端中编辑命令?

vim - 如何向特定缓冲区发送命令?

vim:显示列表字符会更改屏幕环绕

vim - vim 中的 $PATH 与 shell 中的 $PATH 不同? (苹果机)

vim - 使用 VIM 修复格式错误的代码

vim - 如何搜索选定的文本?

regex - vim 和 csv 文件 : put header info into a new column

vim - 在 vim 中防止插入模式