Selectively disabling the "indent" filetype plugin for specific file types in Vim 7.3

I have vim 7.3, with the setting that Ubuntu 11.04 installed by default. My .vimrc looks like this:

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

filetype plugin indent on
let g:omni_sql_no_default_maps = 1 " Stops Omni from grabbing left/right keys

" syntax, colorscheme and status line directives omitted.

How to selectively disable this indentation for different file types (e.g. php, phtml, rb)?

So far I have tried autocmd FileType php filetype plugin indent offseveral options, but I have not succeeded yet.

(Deleting a line filetype plugin ...leads to the desired behavior, but explicitly affects all file types, not just a few.)

+5
source share
3 answers

Prince suggestion with autocmd does not work for me. It does:

filetype plugin on
autocmd BufRead,BufNewFile * filetype indent off
autocmd BufRead,BufNewFile *.py filetype indent on

filetype indent on python. , set ai, .

+4

filetype indent on $VIMRUNTIME/indent.vim, $VIMRUNTIME/indent/[type].vim. , default indent.vim, ( .vim/indent.vim).

, / vimrc :

filetype plugin on
au FileType c,vim,lisp filetype indent on

(, , ). .

+4

, filetype indent , :

    :filetype indent off

[...] "indoff.vim" "runtimepath". . . Reset'autoindent', 'cindent', 'smartindent' / 'indentexpr' .

If you want, as in this online help, to disable the indentation for some types of files, you can put this in your .vimrc:

filetype plugin indent on
au filetype php,phtml,rb call DisableIndent()

function! DisableIndent()
        set autoindent&
        set cindent&
        set smartindent&
        set indentexpr&
endfunction

Also, be sure to understand which of these options you turn off by accessing online help (for example, :help autoindent).

+3
source

All Articles