Vim highlighting weird parts of FORTRAN

社会主义新天地 提交于 2019-12-21 04:34:10

问题


I am using VIM theme molokai, if that makes any difference.

I have been learning FORTRAN lately and when I write a FORTRAN program using VIM, I have weird coloring depending on my whitespace.

For instance, if I tab things over as is (no indenting) I have this purple highlight on only a portion of the word (sometimes it isn't there, notice the PRINTs and READs).

If I tab it over it looks normal:

I am new to VIM (not to mention FORTRAN) so I am not sure what's happening, I don't mind tabbing over all the time but I think it looks a little ridiculous if the whole program is wasting that column of white space.


回答1:


If you search :help fortran, you'll get a list of options that you can set. These are the fortran options I set in my own .vimrc file. (I don't work with fixed-format code though) I know there are one or two fortran specific scripts that are available online, but I don't use them.

let fortran_free_source=1
let fortran_have_tabs=1
let fortran_more_precise=1
let fortran_do_enddo=1



回答2:


Vim was using fixed-format/punchcard when I created a new .f90 file. In order to differentiate it, I found this. I copied it to my ~/.vim/syntax/ directory and added the following lines to my .vimrc (also specified at following link)

nmap <S-F> :set syntax=fortran<CR>:let b:fortran_fixed_source=!b:fortran_fixed_source<CR>:set syntax=text<CR>:set syntax=fortran<CR>
nmap <C-F> :filetype detect<CR>

Allowing me to bind Shift-F to switch formats, and Ctrl-F to auto detect.




回答3:


You can install the Fortran F90/95 indentation rules script in ~/.vim/after/indent, and it should fix the index errors.



来源:https://stackoverflow.com/questions/24147878/vim-highlighting-weird-parts-of-fortran

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!