繁体   English   中英

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

[英]syntax error: unexpected end of file and etc. problems in .vimrc

以我对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

发生错误是因为.vimrc文件是由vim texteditor而不是bash shell读取的。 source .vimrc没有意义,因为bash无法理解(也不希望)该文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM