VIM 在按回车键时向换行符添加一个字符

标签 vim

我环顾四周,但没有找到答案。我有一个 CentOS 6.2 服务器运行与我的 CentOS 5.8 服务器相同的 .vimrc,但是当我在 6.2 服务器上的 VIM 中按 Enter 键时,它会添加上一行的第一个字符,如果它是某个字符(% 或 # 是我见过的)。这就是 VIM 中发生的事情(秒行是在按 Enter 之后,但没有输入任何其他内容):

# <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

对它和我的 5.8 服务器(我没有这个问题)上的那个进行了比较,并且根本没有区别。知道为什么会发生这种情况吗?

最佳答案

它看起来像 automatic comment insertion .

看看 :help formatoptions 和 :set formatoptions。这些可能是按文件类型设置的。

关于VIM 在按回车键时向换行符添加一个字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11154362/

相关文章:

Vim textwidth 逗号缩进问题

vim - 在 Vim 中的代码块周围制作一个 ascii 框

linux - 如何删除 vim 7+ 的所有语法颜色真的很烦我

vim - 用二合字母框装饰文本 block

ruby - VIM 中更好的自动完成功能

regex - 在 VIM 中,为什么不必在搜索和替换中添加回 '$'?

Vim (vim + nvim) 多次源文件

linux - 如何尽快删除一个段落

python - 在 GTK 应用程序中包含控制台应用程序

c++ - 将 c++11 正确添加到 Syntastic