Fortran 77 comment syntax highlighting not working in vim

I have code written in Fortran 77 and I read it using vim. The code is written in such a way that the comments are in lines starting with c, as is customary in Fortran 77. However, vim does not recognize them and therefore uses coloring syntax, which makes the code very difficult to read! How can I overcome this?

I saw that there is a message with the same problem . I read the answers and tried the various solutions that were suggested:

  • add let fortran_have_tabs=1to .vimrc

  • add

    syn match fortranComment excludenl "^[!c*].*$" contains=@fortranCommentGroup,@spell
    syn match fortranComment excludenl "!.*$" contains=@fortranCommentGroup,@spell
    

    to.vimrc

but they do not work for me. Does anyone know why? Am I mistaken somewhere? Otherwise, does anyone have any other suggestion?

+5
1

, .vimrc:

let fortran_have_tabs=1
if has('syntax') && (&t_Co > 2)
    syntax enable
endif

, , syntax enable. :

filetype on

:help ft-fortran-syntax ( : http://vimdoc.sourceforge.net/htmldoc/syntax.html#ft-fortran-syntax). , , , ~/.vim/ftplugin/fortran.vim :

let s:extfname = expand("%:e")
if s:extfname ==? "f90"
  let fortran_free_source=1
  unlet! fortran_fixed_source
else
  let fortran_fixed_source=1
  unlet! fortran_free_source
endif

.vimrc:

filetype plugin indent on

, .

+2

All Articles