Re: .F90 as well as .f90
- On 2003-06-23, Curtis Cooper <curtis@...> wrote:
> Hi,Vim's filename suffix to filetype translation is performed by the
> I'm trying to write a proper .vimrc file that recognizes .F90 files as
> Fortran 90 source code files. It already works for .f90 files, i.e., as
> soon as I type
> > vim file1.f90,
> Vim automatically recognizes the file as Fortran source file and provides
> appropriate syntax highlighting, correct tabbing rules, etc.
> However, when I have a file file2.F90, Vim does not recognize it properly
> as a Fortran 90 source code file. Hence, I get no syntax highlighting for
> this file without first typing
> :set syntax=fortran
> at the Vim command.
script $VIMRUNTIME/filetype.vim. The version of that file shipped
with vim-6.2 includes these lines:
au BufNewFile,BufRead *.f,*.F,*.for,*.fpp,*.ftn,*.f77,*.f90,*.f95 setf fortran
As you can see, the F90 suffix is not in the list. The proper way
to fix this is to create your own ~/.vim/filetype.vim (for Unix)
script and edit it to contain these lines:
au! BufRead,BufNewFile *.F90 setfiletype fortran
as shown under
> Here is the line in my .vimrc currently that I expected would work butYou were confusing file types with file name suffixes. The correct
> does not produce the expected behavior:
> autocmd FileType f,F,f90,F90 set formatoptions=croql cindent et comments=sr:!
> Because F90 is listed as well, it should work as well as f90. Does anyone
> know what's wrong?
syntax for an autocommand that makes those settings for fortran
files is either
autocmd FileType fortran setlocal formatoptions=croql cindent et comments=sr:!
au BufNewFile,BufRead *.f,*.F,*.for,*.fpp,*.ftn,*.f77,*.f90,*.F90,*.f95 setlocal formatoptions=croql cindent et comments=sr:!
Note the use of "setlocal" instead of "set" so that the settings
apply locally to just that buffer instead of globally to every
buffer. But if you're happy with vim's settings for .f90 files and
you fix your filetype detection as described above, you shouldn't
need either of those. If you decide you do want to change some
setting for fortran files only, you should consider putting the
commands in a file,
Gary Johnson | Agilent Technologies
garyjohn@... | Wireless Division
| Spokane, Washington, USA