Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
you can use setlocal for local buffer settings –  juanpablo Nov 13 '11 at 5:06

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.