Emacs
From Liki
Contents |
emacs shortcuts
In emacs, to save a file:
cntrl-x-s
To close a file:
cntrl-x-c
To compile latex in emacs:
cntrl-c-f
Latex in Emacs
Emacs has support for syntax highlighting for various file format include .tex files for tex/latex. This can be turned on / off with the command
alt-x global-font-lock-mode <enter>
As mentioned above, latex code may be compiled by
ctrl-c-f
In addition, the xdvi preview may be started automatically with
ctrl-c-v
One other handy feature is to comment or uncomment a region of text. Just highlight the region with the cursor and then press
alt-;
This will toggle the commenting on a region.
Options
There are some useful options under the options menu. One is 'Syntax Highlighting' which writes text in different colors automatically if they correspond to known commands or syntax in some language. If your file ends in a known extension, like .c, .f, .html, .tex, etc... then Emacs knows what commands and structures look like in these languages and automatically changes their colors appropriately.
Another is 'Paren Match Highlighting' which, whenever you type a closing parenthesis of some sort (could be (, [, or { ), will momentarily highlight its cooresponding opening parenthesis. The color is blue if the parenthesis type matches and purple if they do not match {a open brace and closing bracket, for example]. This can be a real lifesaver when writing long computer codes.
Tools
Under the tools menu you will find, among other things, a multi-lingual spell checker.
Program Specific Menus
Like the Syntax Highlighting mode above, Emacs loads special menus based on the current document type. If your file is html, the menus have options for adding various tags. If it's a TeX file, you get options for TeXing the document.
Editing the .emacs File
Emacs is now default to run in an inverted color mode, with a black background and white writing. This can be altered by editing your .emacs file. In your home directory, type:
emacs .emacs
To change the colors of your background and text, type:
;; Changing Colors (set-background-color "white") (set-foreground-color "black")
The two semicolons indicate a comment. To change the size of the text, since the defauly is a bit bigger than the previous setting, in .emacs file type:
;; Changing Font Size (set-default-font "wxh")
Where w=width and h=height. The current settings are w=9 and h=15. The previous settings were w=8 and h=13. This alteration to the file makes emacs take a bit longer to load.
To make the scroll-wheel work, which it does not automatically, type:
;; Scroll Wheel Activation (mouse-wheel-mode)
Emacs has a nasty habit of creating a bunch of temporary files and not deleting them (i.e. work.txt.~1~, work.txt.~2~). Here is a handy way to remove these files automatically:
;; Cleaning up folders
(setq backup-directory-alist (quote (("" . "/home/newton#/your_directory_name/.backup"))))
If the behavior of the 'tab' key is unacceptable, it can be modified as follows:
;; Adjusting the 'tab' key (global-set-key (kbd "TAB") 'tab-to-tab-stop) (setq-default tab-stop-list (list 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80))
This causes the cursor to stop at the next location designated by the tab-stop-list when the 'tab' key is pressed. This command is for 4 spaces per 'tab', but can be modified to any spacing you want.
Here is a link to a site from Gnu on how to make more changes.
Org mode
I recently installed Org mode, a tool for organizing text notes or project plans in emacs, and it's quite a bit of fun to play around with. Installation is easy for emacs 21.4, and it's well covered in the documentation. Some versions of emacs even ship with Org mode by default, but you'll still need to alter your .emacs file to get org-mode to start automatically when you open .org files. Anyhow, thought I'd pass around the heads up ;).
Alright, my home computer didn't have this problem, but on my lab computer with Ubuntu emacs 22.1.1 I had to add
(setq browse-url-browser-function 'browse-url-firefox)
to my .emacs file to get external links working from org-mode. I don't know what it was attempting to run instead.

