簡體   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