语法错误:.vimrc中的文件意外结束等问题

时间:2018-10-23 07:49:05

标签: linux macos shell unix

根据我对Shell的有限经验,我不知道如何解决此错误。

谢谢。

以下是例外:

[user@pc-name ~]$ source .vimrc 
 -bash:  Configuration file for vim
 set modelines=0        : command not found
 -bash:  Normally we use vim-extensions. If you want true vi- 
 compatibility
 : command not found
 -bash: .vimrc: line 45: unexpected EOF while looking for matching `"'
 -bash: .vimrc: line 48: syntax error: unexpected end of file

这是我的.vimrc

[user@pc-name ~]$ cat .vimrc 
" Configuration file for vim
set modelines=0         " CVE-2007-2438

" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
set nocompatible        " Use Vim defaults instead of 100% vi 
compatibility
set backspace=2         " more powerful backspacing

" Don't write backup file if vim is being called by "crontab -e"
au BufWrite /private/tmp/crontab.* set nowritebackup nobackup
" Don't write backup file if vim is being called by "chpass"
au BufWrite /private/etc/pw.* set nowritebackup nobackup

syntax enable
set background=dark
colorscheme solarized

filetype on             " 检测文件的类型

set number              " 显示行号
set cursorline          " 用浅色高亮当前行
"autocmd InsertLeave * se nocul
"autocmd InsertEnter * se cul

set tabstop=4           " Tab键的宽度
set softtabstop=4
set shiftwidth=4        " 统一缩进为4

set autoindent          " vim使用自动对齐,也就是把当前行的对齐格式应用到下一行(自动缩进)
set cindent             " (cindent是特别针对 C语言语法自动缩进)
set smartindent         " 依据上面的对齐格式,智能的选择对齐方式,对于类似C语言编写上有用

set scrolloff=3         " 光标移动到buffer的顶部和底部时保持3行距离

set incsearch           " 输入搜索内容时就显示搜索结果
set hlsearch            " 搜索时高亮显示被找到的文本

set foldmethod=indent   " 设置缩进折叠
set foldlevel=99        " 设置折叠层数
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
                    " 用空格键来开关折叠

" 自动跳转到上次退出的位置
if has("autocmd")
    au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif

1 个答案:

答案 0 :(得分:1)

发生错误是因为.vimrc文本编辑器而非您的vim shell读取了bash个文件。 source .vimrc毫无意义,因为bash无法理解(也不希望)该文件。