Emacs F90 Mode Quick Reference
January 21, 2011
f90-mode is a major mode for GNU Emacs for editing free-form Fortran
source code. f90-mode is part of GNU Emacs and therefore no
installation is required. To ensure that f90-mode loads when
editing .f90 files and to turn on abbrev-mode and the maximum
level of syntax highlighting, add the following to your ~/.emacs
file:
(autoload 'f90-mode "f90" "Fortran 90 mode" t)
(add-hook 'f90-mode-hook 'my-f90-mode-hook)
(defun my-f90-mode-hook ()
(setq f90-font-lock-keywords f90-font-lock-keywords-3)
(abbrev-mode 1) ; turn on abbreviation mode
(turn-on-font-lock) ; syntax highlighting
(auto-fill-mode 0)) ; turn off auto-filling
Editing Commands
| C-c ; | comment or uncomment region |
| M-; | insert or align comment |
| M-C-q | indent subprogram |
| M-C-h | mark subprogram |
| C-c C-f | fill region |
| C-c C-w | insert end |
| C-c RET | break line |
Compilation Commands
The usual emacs compilation system can be used with Fortran programs.
If you have a Makefile for the project you are editing, use M-x compile
to call make -k in the current directory. Compiler output will be shown
in a separate window. To jump to the first error or warning press
C-x `. Pressing this again will jump to the next error and so on.
Keyword Abbreviations
When using abbrev-mode, f90-mode provides several abbreviations
for typing common keywords. All abbreviations begin with the
backquote character (`). Some common abbreviations are listed
below. Press `? to to list all of the supported abbreviations.
| Abbreviation | Expansion |
|---|---|
| al | allocate |
| ab | allocatable |
| c | character |
| cl | close |
| cx | complex |
| cn | contains |
| cy | cycle |
| de | deallocate |
| di | dimension |
| dp | double precision |
| dw | do while |
| el | else |
| eli | else if |
| elw | elsewhere |
| fl | forall |
| fo | format |
| fu | function |
| fa | .false. |
| im | implicit none |
| in | include |
| i | integer |
| it | intent |
| if | interface |
| lo | logical |
| mo | module |
| nu | nullify |
| op | optional |
| pa | parameter |
| po | pointer |
| pr | print |
| pi | private |
| pm | program |
| pu | public |
| r | real |
| rc | recursive |
| rt | return |
| se | select |
| su | subroutine |
| ta | target |
| tr | .true. |
| t | type |
| wh | where |
| wr | write |