1- *syntax.txt* For Vim version 9.0. Last change: 2023 Apr 24
1+ *syntax.txt* For Vim version 9.0. Last change: 2023 Dec 05
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1591,7 +1591,15 @@ FORTRAN *fortran.vim* *ft-fortran-syntax*
15911591Default highlighting and dialect ~
15921592Highlighting appropriate for Fortran 2008 is used by default. This choice
15931593should be appropriate for most users most of the time because Fortran 2008 is
1594- almost a superset of previous versions (Fortran 2003, 95, 90, and 77).
1594+ almost a superset of previous versions (Fortran 2003, 95, 90, and 77). A
1595+ small number of features new to Fortran 2018 and Fortran 2023 are supported
1596+ and the complete transition to Fortran 2023 will be completed in the future.
1597+ A few legacy constructs deleted or declared obsolescent in recent Fortran
1598+ standards are highlighted as todo items.
1599+
1600+ The syntax script no longer supports Fortran dialects. The variable
1601+ fortran_dialect is now silently ignored. Since computers are much faster now,
1602+ the variable fortran_more_precise is no longer needed and is silently ignored.
15951603
15961604Fortran source code form ~
15971605Fortran code can be in either fixed or free source form. Note that the
@@ -1618,14 +1626,36 @@ neither of these variables have been set, the syntax script attempts to
16181626determine which source form has been used by examining the file extension
16191627using conventions common to the ifort, gfortran, Cray, NAG, and PathScale
16201628compilers (.f, .for, .f77 for fixed-source, .f90, .f95, .f03, .f08 for
1621- free-source). If none of this works, then the script examines the first five
1622- columns of the first 500 lines of your file. If no signs of free source form
1623- are detected, then the file is assumed to be in fixed source form. The
1624- algorithm should work in the vast majority of cases. In some cases, such as a
1625- file that begins with 500 or more full-line comments, the script may
1626- incorrectly decide that the fortran code is in fixed form. If that happens,
1627- just add a non-comment statement beginning anywhere in the first five columns
1628- of the first twenty-five lines, save (:w) and then reload (:e!) the file.
1629+ free-source). No default is used for the .fpp and .ftn file extensions because
1630+ different compilers treat them differently. If none of this works, then the
1631+ script examines the first five columns of the first 500 lines of your file. If
1632+ no signs of free source form are detected, then the file is assumed to be in
1633+ fixed source form. The algorithm should work in the vast majority of cases.
1634+ In some cases, such as a file that begins with 500 or more full-line comments,
1635+ the script may incorrectly decide that the code is in fixed form. If that
1636+ happens, just add a non-comment statement beginning anywhere in the first five
1637+ columns of the first twenty-five lines, save (:w), and then reload (:e!) the
1638+ file.
1639+
1640+ Vendor extensions ~
1641+ Fixed-form Fortran requires a maximum line length of 72 characters but the
1642+ script allows a maximum line length of 80 characters as do all compilers
1643+ created in the last three decades. An even longer line length of 132
1644+ characters is allowed if you set the variable fortran_extended_line_length
1645+ with a command such as >
1646+ :let fortran_line_length=1
1647+ placed prior to the :syntax on command.
1648+
1649+ If you want additional highlighting of the CUDA Fortran extensions, you should
1650+ set the variable fortran_CUDA with a command such as >
1651+ :let fortran_CUDA=1
1652+ placed prior to the :syntax on command.
1653+
1654+ To activate recognition of some common, non-standard, vendor-supplied
1655+ intrinsics, you should set the variable fortran_vendor_intrinsics with a
1656+ command such as >
1657+ :let fortran_vendor_intrinsics=1
1658+ placed prior to the :syntax on command.
16291659
16301660Tabs in fortran files ~
16311661Tabs are not recognized by the Fortran standards. Tabs are not a good idea in
@@ -1647,8 +1677,8 @@ subprograms, block data subprograms, interface blocks, and modules. If you
16471677also set the variable fortran_fold_conditionals with a command such as >
16481678 :let fortran_fold_conditionals=1
16491679 then fold regions will also be defined for do loops, if blocks, and select
1650- case constructs. If you also set the variable
1651- fortran_fold_multilinecomments with a command such as >
1680+ case constructs. If you also set the variable fortran_fold_multilinecomments
1681+ with a command such as >
16521682 :let fortran_fold_multilinecomments=1
16531683 then fold regions will also be defined for three or more consecutive comment
16541684lines. Note that defining fold regions can be slow for large files.
@@ -1659,58 +1689,6 @@ you set foldmethod=syntax. Comments or blank lines placed between two program
16591689units are not folded because they are seen as not belonging to any program
16601690unit.
16611691
1662- More precise fortran syntax ~
1663- If you set the variable fortran_more_precise with a command such as >
1664- :let fortran_more_precise=1
1665- then the syntax coloring will be more precise but slower. In particular,
1666- statement labels used in do, goto and arithmetic if statements will be
1667- recognized, as will construct names at the end of a do, if, select or forall
1668- construct.
1669-
1670- Non-default fortran dialects ~
1671- The syntax script supports two Fortran dialects: f08 and F. You will probably
1672- find the default highlighting (f08) satisfactory. A few legacy constructs
1673- deleted or declared obsolescent in the 2008 standard are highlighted as todo
1674- items.
1675-
1676- If you use F, the advantage of setting the dialect appropriately is that
1677- other legacy features excluded from F will be highlighted as todo items and
1678- that free source form will be assumed.
1679-
1680- The dialect can be selected in various ways. If all your fortran files use
1681- the same dialect, set the global variable fortran_dialect in your .vimrc prior
1682- to your syntax on statement. The case-sensitive, permissible values of
1683- fortran_dialect are "f08" or "F". Invalid values of fortran_dialect are
1684- ignored.
1685-
1686- If the dialect depends upon the file extension, then it is most convenient to
1687- set a buffer-local variable in a ftplugin file. For more information on
1688- ftplugin files, see | ftplugin | . For example, if all your fortran files with
1689- an .f90 extension are written in the F subset, your ftplugin file should
1690- contain the code >
1691- let s:extfname = expand("%:e")
1692- if s:extfname ==? "f90"
1693- let b:fortran_dialect="F"
1694- else
1695- unlet! b:fortran_dialect
1696- endif
1697- Note that this will work only if the "filetype plugin indent on" command
1698- precedes the "syntax on" command in your .vimrc file.
1699-
1700- Finer control is necessary if the file extension does not uniquely identify
1701- the dialect. You can override the default dialect, on a file-by-file basis,
1702- by including a comment with the directive "fortran_dialect=xx" (where xx=F or
1703- f08) in one of the first three lines in your file. For example, your older .f
1704- files may be legacy code but your newer ones may be F codes, and you would
1705- identify the latter by including in the first three lines of those files a
1706- Fortran comment of the form >
1707- ! fortran_dialect=F
1708-
1709- For previous versions of the syntax, you may have set fortran_dialect to the
1710- now-obsolete values "f77", "f90", "f95", or "elf". Such settings will be
1711- silently handled as "f08". Users of "elf" may wish to experiment with "F"
1712- instead.
1713-
17141692The syntax/fortran.vim script contains embedded comments that tell you how to
17151693comment and/or uncomment some lines to (a) activate recognition of some
17161694non-standard, vendor-supplied intrinsics and (b) to prevent features deleted
0 commit comments