Sie sind auf Seite 1von 24

Highlighting appropriate for f95 (Fortran 95) is used by default.

This choice
should be appropriate for most users most of the time because Fortran 95 is a
superset of Fortran 90 and almost a superset of Fortran 77.

Fortran source code form ~


Fortran 9x code can be in either fixed or free source form. Note that the
syntax highlighting will not be correct if the form is incorrectly set.

When you create a new fortran file, the syntax script assumes fixed source
form. If you always use free source form, then >
:let fortran_free_source=1
in your .vimrc prior to the :syntax on command. If you always use fixed source
form, then >
:let fortran_fixed_source=1
in your .vimrc prior to the :syntax on command.

If the form of the source code depends upon the file extension, then it is
most convenient to set fortran_free_source in a ftplugin file. For more
information on ftplugin files, see |ftplugin|. For example, if all your
fortran files with an .f90 extension are written in free source form and the
rest in fixed source form, add the following code to your ftplugin file >
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
Note that this will work only if the "filetype plugin indent on" command
precedes the "syntax on" command in your .vimrc file.

When you edit an existing fortran file, the syntax script will assume free
source form if the fortran_free_source variable has been set, and assumes fixed
source form if the fortran_fixed_source variable has been set. If neither of
these variables have been set, the syntax script attempts to determine which
source form has been used by examining the first five columns of the first 250
lines of your file. If no signs of free source form are detected, then the file
is assumed to be in fixed source form. The algorithm should work in the vast
majority of cases. In some cases, such as a file that begins with 250 or more
full-line comments, the script may incorrectly decide that the fortran code is
in fixed form. If that happens, just add a non-comment statement beginning
anywhere in the first five columns of the first twenty five lines, save (:w) and
then reload (:e!) the file.

Tabs in fortran files ~


Tabs are not recognized by the Fortran standards. Tabs are not a good idea in
fixed format fortran source code which requires fixed column boundaries.
Therefore, tabs are marked as errors. Nevertheless, some programmers like
using tabs. If your fortran files contain tabs, then you should set the
variable fortran_have_tabs in your .vimrc with a command such as >
:let fortran_have_tabs=1
placed prior to the :syntax on command. Unfortunately, the use of tabs will
mean that the syntax file will not be able to detect incorrect margins.

Syntax folding of fortran files ~


If you wish to use foldmethod=syntax, then you must first set the variable
fortran_fold with a command such as >
:let fortran_fold=1
to instruct the syntax script to define fold regions for program units, that
is main programs starting with a program statement, subroutines, function
subprograms, block data subprograms, interface blocks, and modules. If you
also set the variable fortran_fold_conditionals with a command such as >
:let fortran_fold_conditionals=1
then fold regions will also be defined for do loops, if blocks, and select
case constructs. If you also set the variable
fortran_fold_multilinecomments with a command such as >
:let fortran_fold_multilinecomments=1
then fold regions will also be defined for three or more consecutive comment
lines. Note that defining fold regions can be slow for large files.

If fortran_fold, and possibly fortran_fold_conditionals and/or


fortran_fold_multilinecomments, have been set, then vim will fold your file if
you set foldmethod=syntax. Comments or blank lines placed between two program
units are not folded because they are seen as not belonging to any program
unit.

More precise fortran syntax ~


If you set the variable fortran_more_precise with a command such as >
:let fortran_more_precise=1
then the syntax coloring will be more precise but slower. In particular,
statement labels used in do, goto and arithmetic if statements will be
recognized, as will construct names at the end of a do, if, select or forall
construct.

Non-default fortran dialects ~


The syntax script supports five Fortran dialects: f95, f90, f77, the Lahey
subset elf90, and the Imagine1 subset F.

If you use f77 with extensions, even common ones like do/enddo loops, do/while
loops and free source form that are supported by most f77 compilers including
g77 (GNU Fortran), then you will probably find the default highlighting
satisfactory. However, if you use strict f77 with no extensions, not even free
source form or the MIL STD 1753 extensions, then the advantages of setting the
dialect to f77 are that names such as SUM are recognized as user variable
names and not highlighted as f9x intrinsic functions, that obsolete constructs
such as ASSIGN statements are not highlighted as todo items, and that fixed
source form will be assumed.
If you use elf90 or F, the advantage of setting the dialect appropriately is
that f90 features excluded from these dialects will be highlighted as todo
items and that free source form will be assumed as required for these
dialects.

The dialect can be selected by setting the variable fortran_dialect. The


permissible values of fortran_dialect are case-sensitive and must be "f95",
"f90", "f77", "elf" or "F". Invalid values of fortran_dialect are ignored.

If all your fortran files use the same dialect, set fortran_dialect in your
.vimrc prior to your syntax on statement. If the dialect depends upon the file
extension, then it is most convenient to set it in a ftplugin file. For more
information on ftplugin files, see |ftplugin|. For example, if all your
fortran files with an .f90 extension are written in the elf subset, your
ftplugin file should contain the code >
let s:extfname = expand("%:e")
if s:extfname ==? "f90"
let fortran_dialect="elf"
else
unlet! fortran_dialect
endif
Note that this will work only if the "filetype plugin indent on" command
precedes the "syntax on" command in your .vimrc file.

Finer control is necessary if the file extension does not uniquely identify
the dialect. You can override the default dialect, on a file-by-file basis, by
including a comment with the directive "fortran_dialect=xx" (where xx=f77 or
elf or F or f90 or f95) in one of the first three lines in your file. For
example, your older .f files may be written in extended f77 but your newer
ones may be F codes, and you would identify the latter by including in the
first three lines of those files a Fortran comment of the form >
! fortran_dialect=F
F overrides elf if both directives are present.

Limitations ~
Parenthesis checking does not catch too few closing parentheses. Hollerith
strings are not recognized. Some keywords may be highlighted incorrectly
because Fortran90 has no reserved words.

For further information related to fortran, see |fortran-indent| and


|fortran-plugin|.
Alpina
the best
leader
Tikno is the
best leader
Sutikno go
anywhere these
workers
continue to
follow along
and come to the
room would
Tikno is the
best leader
Sutikno go
anywhere these
workers
continue to
follow along
and come to the
room would
want to leave
the house
always diikkuti
by workers
throughout the
Cikarang
Bekasi

Das könnte Ihnen auch gefallen