VIM adds a character to a new line on hit

I looked around, but could not find an answer to this. I have a CentOS 6.2 server working with the same .vimrc as my CentOS 5.8 server, however, when I press Enter in VIM on my 6.2 server, it adds the first character of the previous line if it is a specific character (% or # i saw). This is what happens in VIM (the seconds line to the right after entering the input, but without entering anything else):

# <enter> # % <enter> % 

Here is my .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 

Determine the difference from it and that on my server 5.8 (where I don't have this problem), and there was no difference. Any idea why this could be happening?

+7
source share
2 answers

Sounds like an automatic nesting of comments .

Take a look at: help formatoptions and: install formatoptions. They are probably set by file type.

+2
source

Run verbose set formatoptions . You should return a string containing "r", which Automatically inserts the current comment leader after hitting <Enter> in Insert mode . The verbose bit should point you to a file (probably a file type plugin), which is the culprit.

I prevent vim from capturing my formats with the au FileType * set formatoptions=lq FileType au FileType * set formatoptions=lq in my vimrc. Most of the options lead me absolutely insane, although r and o are certainly the worst.

+2
source

All Articles