Mirror of an article from {jblevins.org} by J. Blevins.

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-qindent subprogram
M-C-hmark subprogram
C-c C-ffill region
C-c C-winsert end
C-c RETbreak 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.

AbbreviationExpansion
alallocate
aballocatable
ccharacter
clclose
cxcomplex
cncontains
cycycle
dedeallocate
didimension
dpdouble precision
dwdo while
elelse
elielse if
elwelsewhere
flforall
foformat
fufunction
fa.false.
imimplicit none
ininclude
iinteger
itintent
ifinterface
lological
momodule
nunullify
opoptional
paparameter
popointer
prprint
piprivate
pmprogram
pupublic
rreal
rcrecursive
rtreturn
seselect
susubroutine
tatarget
tr.true.
ttype
whwhere
wrwrite