vim:smartindent(或cindent)被激活但不起作用

use*_*337 3 vim auto-indent

Vim不会自动执行我正在处理的C源文件,虽然它声称当我输入:set命令时启用了autoindent和cindent选项.当我输入一些代码时,什么也没发生.比如写作

int main()
{
return 0;
}
Run Code Online (Sandbox Code Playgroud)

"返回0;" 声明留在左边.但是,如果我键入"= G"命令,我的文件将缩进.

这是我的配置:

  • ubuntu 13.04
  • vim 7.3.547 + vim-scripts

vimrc分为/ etc/vim/vimrc和〜/ .vimrc.连接内容如下:

runtime! debian.vim

if has("syntax")
  syntax on
endif

set background=dark

" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif

if has("autocmd")
  filetype plugin indent on
endif

set showcmd
set showmatch

if filereadable("/etc/vim/vimrc.local")
  source /etc/vim/vimrc.local
endif

""""""" now this is ~/.vimrc """""

set runtimepath+=,/usr/share/vim-scripts

set autoindent
set noexpandtab                                                                 

" create ~<file> when saving modifications to <file>
set backup

" preserve source's format when pasting
set paste

" disable mouse usage
set mouse=

" colors
set t_Co=256
colorscheme mustang

set hlsearch

set number

set cursorline

if has("statusline")
   hi User1 ctermbg=red cterm=bold,reverse
   hi User2 ctermbg=darkblue cterm=bold,reverse
   hi User3 ctermbg=darkred cterm=bold,reverse
   hi User4 ctermbg=brown cterm=bold,reverse

   set laststatus=2
   set statusline=%h%f\ %y\ %1*%r%*%1*%m%*%=[col:%2*%c%*]\ [line:%3*%.6l%*/%4*%.6L%*\ -\ %p%%]
endif

set spellsuggest=5

match Error /\s\+$/
Run Code Online (Sandbox Code Playgroud)

你有什么主意吗 ?

非常感谢您的帮助.

皮埃尔

rom*_*inl 7

您应该:help paste在添加set paste到您之前阅读~/.vimrc:

When the 'paste' option is switched on (also when it was already on):
    ... skipped ...
    - 'autoindent' is reset
    ... skipped ...
These options keep their value, but their effect is disabled:
    ... skipped ...
    - 'cindent'
Run Code Online (Sandbox Code Playgroud)

'paste'非常有毒的,应该添加到一个人的~/.vimrc.相反,请参阅:help pastetoggle和/或使用p.