2012-06-22 50 views
7

我環顧四周,但還沒有找到答案。我的CentOS 6.2服務器與我的CentOS 5.8服務器運行時具有相同的.vimrc,但是當我在6.2服務器上打入VIM時,它添加了上一行的第一個字符,如果它是某個字符(%或#是我見過的)。這是在VIM會發生什麼(秒數線是按下回車鍵之後,但沒有輸入任何東西):VIM在換行時在換行符上添加了一個字符

# <enter> 
# 

% <enter> 
% 

這裏是我的.vimrc:

set autoindent 
set smartindent 
set tabstop=4 
set shiftwidth=4 
set showmatch 
set number 

imap jj <Esc> " Professor VIM says '87% of users prefer jj over esc', jj abrams disagrees 

" Indenting ******************************************************************* 
set ai " Automatically set the indent of a new line (local to buffer) 
set si " smartindent (local to buffer) 

" Cursor highlights *********************************************************** 
"set cursorline 
"set cursorcolumn 

" Set an orange cursor in insert mode, and a red cursor otherwise. 
" Works at least for xterm and rxvt terminals. 
" Does not work for gnome terminal, konsole, xfce4-terminal. 
"if &term =~ "xterm\\|rxvt" 
" :silent !echo -ne "\033]12;red\007" 
" let &t_SI = "\033]12;orange\007" 
" let &t_EI = "\033]12;red\007" 
" autocmd VimLeave * :!echo -ne "\033]12;red\007" 
"endif 

" Searching ******************************************************************* 
set hlsearch " highlight search 
set incsearch " Incremental search, search as you type 
set ignorecase " Ignore case when searching 
set smartcase " Ignore case when searching lowercase 

" Colors ********************************************************************** 
"set t_Co=256 " 256 colors 
set background=dark 
syntax on " syntax highlighting 
"colorscheme darkzen 

冉DIFF反對和一個在我的5.8服務器(我沒有這個問題),並沒有任何區別。任何想法爲什麼這可能會發生?

+6

+1:'VIM教授說'87%的用戶更喜歡jj over esc',jj abrams不同意 –

+0

取決於文件類型插件。 –

回答

2

運行verbose set formatoptions。您應該找回包含'r'的字符串,其中Automatically inserts the current comment leader after hitting <Enter> in Insert modeverbose位應該指向你的文件(可能是一個文件類型插件)是誰的罪魁禍首。

我防止vim在我的vimrc中通過自動命令au FileType * set formatoptions=lq劫持我的格式選項。大多數選項讓我非常瘋狂,儘管ro是迄今爲止最糟糕的。

+0

我愛你的答案,這確實是r和o搞亂了我。非常感謝你,它變得非常煩人。 –