Skip to main content

2.5 More on modes

In the in-built emacs tutorial, you would have encountered the concept of major and minor modes in emacs. One mode you were introduced to is the auto-fill-mode.

In scientific computing, there are some other modes which are also useful. These are:

  1. fortran-mode
  2. c-mode
  3. shell-script-mode
  4. font-lock-mode

The first two are useful for when you are editing fortran or c source files. The third is useful for editing shell-scripts. The last mode is useful generally, since it will highlight different classes of text in different colours - but is only really handy when used in conjunction with another mode. For example, in fortran mode, font-locking will highlight comment statements in red, and so on. It makes source code much easier to read.

fortran-mode will kick in automatically if you emacs a file ending in ".f". Same goes for c-mode and files ending in ".c"

You can switch on font-lock-mode to start automatically if you put the following lines in your .emacs file (in your top directory)
;; turn on font-lock mode
(global-font-lock-mode t)