On 9/20/06, Yakov Lerner <[EMAIL PROTECTED]> wrote:
On 9/20/06, Fabien Meghazi <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a lot of python files without the .py extensions as I'm using > them as commands, those files are scripts in my ~/bin with execute bit > set. > I set up my editing environment for python files in my .vimrc using > autocmd using pattern *.py > But I would like these autocmd's to match those files whitout .py extensions. > > My question is : > > Is it possible to make an autocmd pattern's to match something in the > first line's buffer with a regexp eg: ( ^#\!.+python or something > like that ) instead of the filename ?We typically do it as follows: :au BufReadPost * if getline(1) =~ 'pattern' | do something | endif
:au BufReadPost * if getline(1) =~ '^#!.*python' | set filetype=python | endif (untested.) Yakov
