On Fri, 13 Jan 2012, Taylor Hedberg wrote:

carugnom, Fri 2012-01-13 @ 10:45:55-0800:
Does somebody have a vim configuration example, where separated configuration files by each language (c, python, etc) can be used. So when i open a .c source, configuration for c files is applied, when i open a .py source, configuration for python files is applied, and so on

This is called an "ftplugin" (file type plugin). Just write a script, and name it <filetype>.vim, where <filetype> is the name of the file type you want it to apply to ("c" for C source files, "python" for Python, etc.). Then put it in your ~/.vim/ftplugin directory and it should take effect the next time you load a buffer with that filetype.

If you want more than one script to execute for a given filetype, there is an alternate method: Rather than naming the script <filetype>.vim and putting it in ~/.vim/ftplugin, you can instead create a directory called ~/.vim/ftplugin/<filetype> and place any number of scripts in that directory. They will all be sourced when loading a buffer of that type.

In addition to:

~/.vim/ftplugin/<filetype>.vim
and
~/.vim/ftplugin/<filetype>/<name>.vim

There is also:

~/.vim/ftplugin/<filetype>_<name>.vim

So, e.g., I have, from various sources:

~/.vim/ftplugin/gitcommit.vim
~/.vim/ftplugin/gitcommit_hi.vim

See:

:help ftplugin-name

--
Best,
Ben

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to