xic
xic

Reputation: 3

Can I turn on Fortran syntax highlight with ".h" file in vim?

I am working on a Fortran project. The author keeps all function interfaces in the ".F90" file between the "module/end module" part, and keeps all the implementation in a separate ".h" file. A "#include" command is used at the end of the module section.

I am trying to study the implementation code. Unfortunately, vim does not treat the .h file as a fortran source code, and I could not turn on the syntax highlight. Is there a way to get the syntax highlight on?

Best regards,

Upvotes: 0

Views: 462

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172688

You can override the detected syntax / filetype (probably C for *.h files) with

:setlocal filetype=fortran

also while opening:

:edit +setf\ fortran file.h

If you need this often (and don't usually edit C/C++ header files), you can also adapt the default filetype detection rules; cp. :help ftdetect.

(This all assumes you have syntax highlighting turned on via :syntax on in your ~/.vimrc.)

Upvotes: 1

Related Questions