Thursday, March 1, 2012

Re: how to change tab and shiftwidth behaviour depending on file type.

skrite, Thu 2012-03-01 @ 08:15:12-0800:
> i do a lot of work in python and a lot in ruby, html, and javascript.
> What i would like is for all my python files to behave with 1 tab = 4
> spaces, with the correct indent, etc.. But on the ruby,html,and
> javascript, i need only 2 spaces.
>
> In both cases, i need the tabs converted to spaces.
>
> how would i set something like this up?

Write a script that sets the options as you want them for a particular
filetype, then save it as ~/.vim/ftplugin/python.vim,
~/.vim/ftplugin/ruby.vim, etc.

See also: `:help ftplugin`.

No comments: