1

I am using VIM 7.4 with syntax highlighting on some Fortran77 source code. One comment has a single apostrophe that never is repeated/closed (eg * Bert's bees), causing the remaining source code to be highlighted as a string.

! comment ignores apostrophe's as string
c A comment where apostrophe's are considered strings
* This comment is displaying fully as a string
C Comment with the closing apostrophe, it's not great

PROGRAM myexample

END PROGRAM

My .vimrc has been cleaned to only contain :syntax on and my .vim folder has been deleted. This is what I am seeing in Putty:

Image

I would assume the problem is the default fortran.vim file isn't correctly grabbing the comment labels for c, C, and d, but is working for ! comments (where it correctly ignores the apostrophe).

  • What Vim version is this? – Christian Brabandt Jun 10 at 15:26
  • Standard Fortran plugin does not seem to recognize strings embedded in comments. You probably have some local plugins/modifications. – Matt Jun 10 at 15:47
  • @Matt I have been able to reproduce the issue by only using the following in the .vimrc document: filetype plugin indent on :syntax on I guess I will remove this and see if things are better. – Brandon Groth Jun 10 at 16:56
2

This behaviour is also in the latest Vim. It seems comments in the form of c text and * text are not recognized at all, only ! text comments are.

Looking at $VIMRUNTIME/syntax/fortran.vim it loos like it modifies the syntax highlighting behaviour to match various Fortran dialects. :help ft-fortran-syntax has some more details on this.

Adding let g:fortran_fixed_source = 1 to my vimrc seems to fix the comment problem for me, although it now gives errors on the PROGRAM and END lines, which are "left margin errors" according to the comment in the syntax file. I'm not familiar with Fortran at all, but it seems to require numbers and/or indentation before the actual code. let g:fortran_have_tabs = 1 can be used to disable that, if you want.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.