Wednesday, September 26, 2012

Re: VIM and Fortran Syntax Highlighting Error when Creating New File

On Tuesday, September 25, 2012 7:12:41 PM UTC-5, Paul Lou wrote:
> Hello all,
>
> First I'd like to thank the VIM team for creating one of the best and most flexible editors in the world.
>
> I just started learning VIM with Fortran, and I realized a syntax coloring problem when creating a Fortran file through
>
> vim example.f
>
> As shown in shot.png, the syntax coloring is only working partially.
>
> However, if I reopen the file, the syntax coloring will be fully working, as shown in shot2.png.

As you guessed, it looks like somehow the wrong filetype/syntax is being loaded. What is the output of the following, before and after reopening?

:verbose set filetype?

What command did you use to open the file? What command did you use to "reopen" the file?

>
> I tried to add
>
> au BufNewFile,BufReadPost *.f,*.for,*.fpp,*f95,*f90 setf fortran
>
> into .vimrc but it doesn't seem to work.

:setfiletype is designed to NOT take any action if the filetype has already been set in a chain of autocmd events. As a workaround, try "setl filetype=fortran" instead of "setf fortran". But this is a workaround. You should figure out why Vim is detecting the wrong filetype, if this is actually the problem.

>
> I am currently running Debian Wheezy, VIM 7.3.
>
> Is it because Vim shipped in Wheezy is not up to date?
>

I don't know. What version of Vim ships with Wheezy? Paste the first few lines of output from the :version command in Vim, up to the "Huge/Big/Normal/Tiny version with/without GUI" line. But any version of 7.3 ought to work fine for what you're trying to do, so I doubt very much it's a version problem.

--
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

No comments:

Post a Comment