3

:set コマンドを入力すると、autoindent オプションと cindent オプションの両方が有効になっていると表示されますが、Vim は作業中の C ソース ファイルを自動インデントしません。コードを入力しても何も起こりません。たとえば、書き込み

int main()
{
return 0;
}

「リターン0;」ステートメントは左側に残ります。ただし、「=G」コマンドを入力すると、ファイルがインデントされます。

これが私の設定です:

  • Ubuntu 13.04
  • vim 7.3.547 + vim スクリプト

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\+$/

何か考えはありますか?

ご助力ありがとうございます。

ピエール

4

2 に答える 2