我有一个用 Fortran 77 编写的代码,我用 vim 阅读了它。代码的编写使得注释位于以 c
开头的行上。 ,这是 Fortran 77 中的标准。但是,vim 无法识别它们,因此使用着色语法使代码非常难以阅读!我怎样才能克服这个问题?
我看到有一个 post with the same problem .我已阅读答案并尝试了建议的不同解决方案:
let fortran_have_tabs=1
到 .vimrc syn match fortranComment excludenl "^[!c*].*$" contains=@fortranCommentGroup,@spell
syn match fortranComment excludenl "!.*$" contains=@fortranCommentGroup,@spell
到 .vimrc
但它们对我不起作用。有人知道为什么吗?我在某处犯了错误吗?否则,有人有不同的建议吗?
最佳答案
这在我的 .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
这对我有用,因此我可以毫无问题地查看和编辑自由格式和固定格式。
关于vim - Fortran 77 注释的语法高亮显示在 vim 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11903166/