Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know I can setf python and then the file is recognized as python. However I must redo this everytime I reload the scons file.

I have read some weeks ago that one could write in the last lines of a file with a special syntax and sets parameters that vim should read.

In my case I would like setf python to be set anytime I open this scons file.

However I don't remember the syntax, and I can't manage to find the web site where I read it was possible to have file dependent properties.

#:setf python on the last line doesn't seem to suffice.

share|improve this question
up vote 1 down vote accepted

Correct syntax:

# vim: set filetype=python:

But you need set modeline (it's default in my case) in .vimrc.

Read this wiki for more information.

share|improve this answer

If the scons file always has the same name / adheres to a certain pattern, you can also configure the filetype detection; put the following into your ~/.vimrc:

:autocmd BufNew,BufRead SConstruct setf python
share|improve this answer

Your Answer


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.