【解决】source ~/.vimrc出错bash: /etc/vim/vimrc: line 21: syntax error near unexpected token `"syntax"'

        执行了“source ~/.vimrc”后,一直报如下错误:

bash:  All system-wide defaults are set in /debian.vim and sourced by
: No such file or directory
bash:  settings, you should do it in this file (/etc/vim/vimrc), since debian.vim
: No such file or directory
 It is recommended to make changes after sourcing debian.vim since it alters
: command not found
 This line should not be removed as it ensures that various options are
: command not found
runtime!: command not found
 Uncomment the next line to make Vim more Vi-compatible
: command not found
 options, so any other options should be set AFTER setting 'compatible'.
set: command not found
 Vim5 and later versions support syntax highlighting. Uncommenting the next
: command not found
bash: /etc/vim/vimrc: line 21: syntax error near unexpected token `"syntax"'
bash: /etc/vim/vimrc: line 21: `if has("syntax")'

        bash: /root/.vimrc: line 13: syntax error near unexpected token `('
        bash: /root/.vimrc: line 13: `silent! if plug#begin('~/.vim/plugged')'

        一度认为我改错了,害得我重装了Python和YCM。后面在stackoverflow查到了原因:这不是一个bash脚本。如果你要问以前这么执行为什么没事,我也不知道,这里只贴出解决方案:

        在vim执行这两行指令即可:

:source ~/.vimrc
:source $MYVIMRC

如图1与2所示。

图1 在vim执行“source ~/.vimrc”
图2 在vim执行“source $MYVIMRC”

参考资料:

        [1]参考1

发布了143 篇原创文章 · 获赞 31 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/u25th_engineer/article/details/100126190