Emacs can be configured to add a trailing newline by updating ~/.emacs as follows:
(setq require-final-newline t)
dot-emacseditorselispemacsnewline
To set your own global keybinding to a function, use global-set-key in your ~/.emacs as follows:
(global-set-key "C-cl" 'enlarge-window-horizontally)
configurationdot-emacseditorselispemacskeystrokes
On some systems (and for some terminal types), Emacs' use of the backspace key can be confusing. The backspace key may behave like the Delete key. You can fix this either by using this elisp in your ~/.emacs as follows:
(keyboard-translate ?\C-h ?\C-?)
This shell command may work if the elisp does not:
stty erase '^?'
backspacecrapdeletedot-emacseditorsemacsgotchakeystrokesterminal
Use this in your ~/.emacs to bind a key to goto-line:
(global-set-key "C-cl" 'goto-line)
configurationdot-emacseditorselispemacskeystrokes
To create a macro:
C-x (
Once in macro recording mode, enter a series of commands. When finished:
C-x )
To name the most recently recorded macro:
M-x name-last-kbd-macro
Enter a name for the macro. The name will now be accessible as M-x <name>.
To generate macro elisp suitable for reload, run M-x insert-kbd-macro and enter the name of a defined macro. Paste the resulting code into ~/.emacs.
configurationdot-emacseditorsemacskeystrokesmacros
To get emacs to stop inserting tab characters and insert spaces instead, use this in your ~/.emacs file:
(setq-default indent-tabs-mode nil)
configurationdot-emacseditorsemacsindentationspacestabs
If you use middle-clicking to paste into Emacs windows but don't like how the paste occurs at the click location and would rather paste at point, use this in your ~/.emacs:
(setq mouse-yank-at-point t)
Thanks to Kevin Turner for pointing this out.
configurationdot-emacseditorselispemacsmousepointyank
If you wish for a particular file to be handled with a mode that isn't already associated with its extension, you may put a header like this anywhere in the file:
-*- mode: outline; mode: auto-fill -*-
Alternatively, you can update your ~/.emacs to use modes based on file extension or filename. For example, to use html-mode for files ending in .tpl:
(setq auto-mode-alist
(cons '("\\.tpl$" . html-mode) auto-mode-alist))
You can also configure Emacs to use a specific major and minor mode together for a given file extension. This example defines my-mode to load outline-mode (a major mode) and auto-fill-mode (a minor mode) for files ending in .foo:
(defun my-mode ()
(outline-mode)
(auto-fill-mode))
(setq auto-mode-alist
(append '(("\\.foo$" . my-mode))
auto-mode-alist))
configurationdot-emacseditorselispemacs