Frage

People usually ask how to expand tabs for specific file types -- I want the expansion done on the inverse-set: how to expand tabs for all except for some file types.

I already have a global setting for all files:

set tabstop=4 shiftwidth=4 expandtab softtabstop=4 autoindent

I wish to exclude all files without a filetype and for files ending in .txt. I've already tried stuff like

if &filetype == ""
   setlocal noexpandtab noautoindent
endif

and

autocmd FileType "" set noexpandtab

to no avail. (The first matches my perl files, the second doesn't match anything)

War es hilfreich?

Lösung

It might be that the File Type event is only triggered when a filetype has actually been set, which, in your case, is the exact opposite. I would try something like:

autocmd BufEnter * if &filetype == "" | setlocal noxpandtab | setlocal noautoindent | endif

That should work, maybe you need some other event types than only BufEnter. Also don't forget to wrap your autocmd's in an augroup, or they might be executed multiple times, see http://learnvimscriptthehardway.stevelosh.com/chapters/14.html ;) good luck!

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top