Monday, 30 June 2008

Editing .Emacs

The first thing you need to do is activate highlighting modes. The three fundamental modes are:

(setq-default transient-mark-mode t) ; Active Region highlighting
(global-font-lock-mode t) ; Syntax Highlighting
(setq show-paren-mode t) ; Matching Parentheses highlighting

Then you need to activate various shortcut keys. Some recommended ones:

(global-set-key "\M-g" 'goto-line) ; quickly jump to lines with Meta-X g
(global-set-key [f3] 'query-replace-regexp) ; regex search and replace
(global-set-key [f10] 'load-file) ; load a file (e.g. reload .emacs)

Note: you will sometimes see "\M-g" written as (kbd "M-g") eliminating the need for a backslash.

Finally you need to set some formatting defaults.

(setq c-basic-offset 4)
(setq-default indent-tabs-mode nil)

The last commands here set the factory default for spaces between indentation levels, and sets tabs to spaces, for consistency with source-control systems.


No comments: