I use modern fortran for parallel programming. I use vim, and I was very annoyed that the fortran.vim syntax files did not seem to handle compiler directives such as! $ Omp or! Dir $. They just get as comments in vim, so they don't stand out. In c / C ++, these compiler directives are executed using #pragma, so everything stands out as preprocessor code, not comment code. So I want a similar treatment in fortran syntax. Here is an example of a multi-line directive that I want to colorize:
!$omp parallel do reduction(+: sum0) reduction(+: sum1) &
private( nn, S1, S2, Y1, Y2, rvec0, rvec1, iThreadNum)
What I still have is a new fortran.vim file located in $ HOME / .vim / after / syntax. I have to recognize "! $ Omp" at the beginning of a line and color this line, as well as color multilines correctly. My syntax file contains the following:
syn region fortranDirective start=/!$omp.*/ end=/[^\&]$/
hi def link fortranDirective PreProc
My problem is that now it cannot handle the simple case of just one line. I.e:
!$omp parallel do blah blah
call foobar <
I need some kind of regular expression rule in the syntax file in order to be able to correctly match both a single line and a continuation line. Can anybody help?
source
share