语法高亮的Fortran 77评论在vim中不工作 [英] Syntax highlighting of Fortran 77 comments not working in vim
问题描述
我有一个代码写在Fortran 77,我用vim读它。代码是这样写的,注释是在 c
开始的行上,这是Fortran 77的标准。然而,vim不能识别它们,因此使用着色语法代码很难读!我如何克服这个?
我看到有一个 post有相同的问题。我已经阅读了答案,并尝试了不同的解决方案,建议:
-
添加
c $ c> syn match fortranComment excludenl^ [!c *]。* $contains = @ fortranCommentGroup,@ spelllet fortran_have_tabs = 1 $> $
syn match fortranComment excludenl!。* $contains = @ fortranCommentGroup,@ spell
至.vimrc
但他们不适合我。有人知道为什么吗?我在某个地方犯了错误?
这对我的.vimrc有效:
let fortran_have_tabs = 1
if has('syntax')&& (& t_Co> 2)
语法启用
endif
部分最有可能是语法enable
部分。您可能还需要此:
上的文件类型
还要尝试输入:help ft-fortran-syntax
并阅读(或参见这里: http://vimdoc.sourceforge.net/htmldoc/syntax.html#ft-fortran-syntax )。我从中删除了,我需要创建文件〜/ .vim / ftplugin / fortran.vim
,并把它在其中:
let s:extfname = expand(%:e)
如果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插入缩进
这对我来说,让我可以查看和编辑自由形式和固定形式没有问题。
I have a code written in Fortran 77 and I read it with vim. The code is written such that the comments are on lines starting with c
, as is standard in Fortran 77. However, vim does not recognize them and therefore use a coloring syntax that makes the code very difficult to read! How can I overcome this?
I've seen that there is a post with the same problem. I have read the answers and tried the different solutions that have been suggested:
add
let fortran_have_tabs=1
to .vimrcadd
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 someone know why? Have I made a mistake somewhere? Otherwise, does anyone have a different suggestion?
This is what works for me in my .vimrc:
let fortran_have_tabs=1
if has('syntax') && (&t_Co > 2)
syntax enable
endif
The important part is most likely the syntax enable
part. You may also need this:
filetype on
Also try typing in :help ft-fortran-syntax
and reading that (or see here: http://vimdoc.sourceforge.net/htmldoc/syntax.html#ft-fortran-syntax). What I took away from that was that I needed to create the file ~/.vim/ftplugin/fortran.vim
and put this in it:
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
And also put this in your .vimrc:
filetype plugin indent on
That does the trick for me so that I can view and edit free-form and fixed-form with no problem.
这篇关于语法高亮的Fortran 77评论在vim中不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!