On 4/19/07, Kamaraju S Kusumanchi <address@hidden
> wrote:
Paul Laub wrote:
> http://www.vim.org/scripts/script.php?script_id=1241
> (In my experience, this script by Soren Hauberg works well.)
>
I am currently making this script work. Even after I do what the above
website says, the filetype is detected as conf and not as octave. If I open
the file and then do
:set ft=octave
then the syntax highlighting works fine.
Any ideas?
Looking at the filetype.vim file for vim 7.0 on debian, it looks like there is a function that is run to try to determine the type of a file ending in .m. The check looks like this:
" Matlab or Objective C
au BufNewFile,BufRead *.m call s:FTm()
fun! s:FTm()
let n = 1
while n < 10
let line = getline(n)
if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)'
setf objc
return
endif
if line =~ '^\s*%'
setf matlab
return
endif
if line =~ '^\s*(\*'
setf mma
return
endif
let n = n + 1
endwhile
if exists("g:filetype_m")
exe "setf " . g:filetype_m
else
setf matlab
endif
endfun
So if in the first 10 lines it finds a line beginning in "#include" or "#import" it will assume it is an objc file. If in the first 10 lines if finds a line beginning in "%" it will assume it is matlab, if it finds a line starting in "(*" it will assume mma. If none of those matches, if you have created a filetype_m variable in you .vimrc or other initialization file, it will use that, otherwize it assumes matlab.
Assuming this was something that came with vim and isn't a debian modification, once you have put the octave.vim file in /usr/share/vim/vim70/syntax, you should be able to add the following line to .vimrc
let filetype_m = 'octave'
before syntax on.
And as long as you don't use any of the above in the first 10 lines, it should use the octave highlighting.
I am not sure why you are seeing a "conf" file type, especially since you were seeing the file detected as matlab before.
Bill