views:

15

answers:

0

I have vim (version 7.2) performing nice syntax folding with

:set foldmethod=syntax
:let fortran_fold=1

However, I find that the default vim syntax file for Fortran isn't recognizing character functions that include a length attribute.

For example.

CHARACTER FUNCTION function_name folds just fine,

but

CHARACTER(len=*) FUNCTION function_name does not.

How can I get vim to recognize CHARACTER(len=*) FUNCTION as the start of a fold?

Addition 8/20/10:

Under the encouragement of Idigas, I waded through the mess that is /usr/share/vim/vim72/syntax/fortran.vim

If I understand this right, it looks as through the authors of this file did intend for CHARACTER(len=*) FUNCTION function_name to be folded.

The actual code (regex?) is, I believe line 344:

syn region fortranFunction transparent fold keepend extend start="^\s*\(elemental \|pure \|recursive \)\=\s*\(\(\(real \|integer \|logical \|complex \|double \s*precision \)\s*\((\(\s*kind\s*=\)\=\s*\w\+\s*)\)\=\)\|type\s\+(\s*\w\+\s*) \|character \((\(\s*len\s*=\)\=\s*\d\+\s*)\|(\(\s*kind\s*=\)\=\s*\w\+\s*)\)\=\)\=\s*function\s\+\z(\a\w*\)" skip="^\s*[!#].*$" excludenl end="\<end\s*\($\|function\(\s\+\z1\>\)\=\)" contains=ALLBUT,fortranProgram,fortranModule

Perhaps there is a problem with the regex here? I am finding it hard to decipher as soo many characters appear to be escaped with backslashes. For example, why are equal signs (=) getting escaped?

I think the precise region is:

\|character \((\(\s*len\s*=\)\=\s*\d\+\s*)\|(\(\s*kind\s*=\)\=\s*\w\+\s*)