'How to make vim high-light as python when editing scons files?

I'm using vim to edit SConstruct files of scons, I want to make vim high-light as python grammar automatically. How to do that?

How to associate file name of 'SConstruct' with 'Python' in vimrc?

Thanks



Solution 1:[1]

Add this to your vimrc:

au BufRead,BufNewFile SConstruct set filetype=python

Solution 2:[2]

Create a file in your .vim directory, ftdetect/sconstruct.vim. In it, have the following command:

au BufRead,BufNewFile SConstruct set filetype=python

Usually, in place of 'SConstruct' you would use a wildcard such as '*.py'; but as long as the file name is SConstruct it should work.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Arya McCarthy
Solution 2 nullverb