4

Drupal provides some reference on how to setup VIM for Drupal development, but I want these indentation settings to be applied to only drupal related files instead of all files

set expandtab
set tabstop=2
set shiftwidth=2
set autoindent
set smartindent

is that possible to set these settings to only .module and .inc files?

Not sure if this is relevant, but to provide syntax highlighting to the drupal files, I know the provided configuration would work

if has("autocmd")
  " Drupal *.module and *.install files.
  augroup module
    autocmd BufRead,BufNewFile *.module set filetype=php
    autocmd BufRead,BufNewFile *.install set filetype=php
    autocmd BufRead,BufNewFile *.test set filetype=php
  augroup END
endif

is it possible to put the settings above into this configuration block?

1
  • you can use setlocal for local buffer settings
    – juanpablo
    Nov 13, 2011 at 5:06

1 Answer 1

4

Yes it would be possible, you said you want these settings to only apply to the *.module and *.inc file then I would modify your configuration block to look like this:

if has("autocmd")
  " Drupal *.module and *.install files.
  augroup module
    autocmd BufRead,BufNewFile *.module set filetype=php
    autocmd BufRead,BufNewFile *.install set filetype=php
    autocmd BufRead,BufNewFile *.test set filetype=php

    autocmd BufRead,BufNewFile *.module set expandtab
    autocmd BufRead,BufNewFile *.module set tabstop=2
    autocmd BufRead,BufNewFile *.module set shiftwidth=2
    autocmd BufRead,BufNewFile *.module set autoindent
    autocmd BufRead,BufNewFile *.module set smartindent

    autocmd BufRead,BufNewFile *.inc set expandtab
    autocmd BufRead,BufNewFile *.inc set tabstop=2
    autocmd BufRead,BufNewFile *.inc set shiftwidth=2
    autocmd BufRead,BufNewFile *.inc set autoindent
    autocmd BufRead,BufNewFile *.inc set smartindent

  augroup END
endif

Basically from my understanding of VIM is that almost anything that you can do in the .vimrc file can be done via the :prompt in vim such as :set smartindent for example.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .