web-dev-qa-db-fra.com

Comment configurer VIM pour modifier les fichiers de code Makefile et Normal?

J'utilise Mac OSX 10.7.5, le contenu de .VIMRC est comme suit:

set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set shiftround  
set smarttab    
set autoindent  
set copyindent  

autocmd FileType make setlocal noexpandtab

Ce que j'essaie de faire est que je modifie des fichiers normaux comme .js, .html je veux que mes onglets soient en retrait avec 4 espaces vides au lieu d'un onglet normal.

Mais lorsque je modifie Makefile, j'en ai besoin pour être un onglet normal au lieu de 4 espaces vides pour les empreintes.

Je pensais que la configuration ci-dessus dans .vimrc va me donner cela, mais ne fonctionne pas pour moi comme lorsque je suis en train de modifier Makefile, je reçois toujours 4 espaces vides pour l'indentation.

Je ne sais pas ce que je fais mal ici?

24
forestclown

Ceci est une section de mon .vimrc:

" enable filetype detection:
filetype on
filetype plugin on
filetype indent on " file type based indentation

" recognize anything in my .Postponed directory as a news article, and anything
" at all with a .txt extension as being human-language text [this clobbers the
" `help' filetype, but that doesn't seem to prevent help from working
" properly]:
augroup filetype
  autocmd BufNewFile,BufRead */.Postponed/* set filetype=mail
  autocmd BufNewFile,BufRead *.txt set filetype=human
augroup END

autocmd FileType mail set formatoptions+=t textwidth=72 " enable wrapping in mail
autocmd FileType human set formatoptions-=t textwidth=0 " disable wrapping in txt

" for C-like  programming where comments have explicit end
" characters, if starting a new line in the middle of a comment automatically
" insert the comment leader characters:
autocmd FileType c,cpp,Java set formatoptions+=ro
autocmd FileType c set omnifunc=ccomplete#Complete

" fixed indentation should be OK for XML and CSS. People have fast internet
" anyway. Indentation set to 2.
autocmd FileType html,xhtml,css,xml,xslt set shiftwidth=2 softtabstop=2

" two space indentation for some files
autocmd FileType vim,lua,nginx set shiftwidth=2 softtabstop=2

" for CSS, also have things in braces indented:
autocmd FileType css set omnifunc=csscomplete#CompleteCSS

" add completion for xHTML
autocmd FileType xhtml,html set omnifunc=htmlcomplete#CompleteTags

" add completion for XML
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags

" in makefiles, don't expand tabs to spaces, since actual tab characters are
" needed, and have indentation at 8 chars to be sure that all indents are tabs
" (despite the mappings later):
autocmd FileType make set noexpandtab shiftwidth=8 softtabstop=0

" ensure normal tabs in Assembly files
" and set to NASM syntax highlighting
autocmd FileType asm set noexpandtab shiftwidth=8 softtabstop=0 syntax=nasm

La section devrait être explicite de soi, mais je vous suggère de lire l'aide VIM sur filetype et autocmd.

La ligne la plus pertinente pour vous est probablement celle-ci:

autocmd FileType make set noexpandtab shiftwidth=8 softtabstop=0

assurez-vous que la détection de filetype est activée, cependant.

27
polemon