emacs Notes
These emacs notes are currently a list of random things that I have
found useful from time to time and couldn't really find very easily
without a bit of help or luck. I strongly recommend emacs to be used
as a text editor for LaTeX files, as it has a LaTeX mode (as well as
an HTML mode!) with such features as checking your brackets match -
which means that you don't get pages of LaTeX errors for a
simple bracket mismatch.
For now I've just included a table of commands I use quite often. A
copy of the "official" and indespensible reference card for
emacs is here. A frame-based copy is
available here.
If you were expecting to find out how to do things with
LaTeX, such as making new documents, inserting/manipulating
figures, etc., you need to be looking here.
Random useful Emacs Commands
Rem: M- means the Meta key, and C- means hold down the
control key |
Stuff you should know and use lots
Go to a specific line |
M-x goto-line |
Check bracket matching |
M-x validate-buffer |
More cursor forward by a word |
C-(leftarrow) |
Go to end of line |
C-e |
Go to start of line |
C-a |
Save file |
C-xs |
Query save each file in buffer (i.e. LaTeX will offer you the
option to save each edited file |
C-x s (i.e. don't hold crtl down for s) |
Setting a mark (e.g. so you can remove text between the mark and
the cursor |
C-<space> |
In case of disaster...
(a.k.a. undoing errors) |
C-<shift>- (can use this repeatedly) |
|
|
Query replace - searches for a string and gives the option to
replace it with another string
|
M-x query-replace |
Replace string - replaces all strings with alternative string
without querying
|
M-x replace-string |
|
|
|
|
|
Cool stuff
removing a rectangle |
1. Set a mark at the top left corner of the rectangle you want to
remove
2. Position the cursor at the bottom right corner
3. hit: C-x r k |
Adding a rectangle |
1. Set a mark at the top left corner of where you want to put the rectangle
2. Position the cursor at the bottom right corner of your rectangle
(this can be vertically below the first mark, or can be several spaces
along, in which case everything in the rectangle will be overwritten
by the rectangle (!))
3. hit: C-x r t then enter the string
you want the rectangle to consist of (e.g. several spaces, characters
to comment out passages of code, etc. Then press <enter> |
Getting rid of annoying MSWindoze characters ^M
(Note: The "^M" object is read as a single character, so
you can't simply type a "^" followed by a "M" in
emacs to remove it.) |
M-x query-replace Then copy and
paste the ^M character into the buffer window using the mouse pointer
- put pointer at the start of the character, hold down left button an
drag pointer so that the whole composite character is
highlighted. Then release mouse button, move mouse pointed to buffer
window and click with the right mouse button to paste in your
selection. Now press <enter> and then press it again to replace
the ^M characters with nothing, i.e. to remove them |
|
|
|
|
|
|
|
|
|
|
|
|
|
Making the most of emacs...
There are a number of setups you can use to get the most out of emacs.
The easiest way to get started is to download someone's .emacs file
which has lots of set-up commands - such as different colours for text
between $...$ to show that something is in math mode. And different colours
on environment labels. It's easy to change the colours - just play with
the .emacs file! Also useful it that if you go the start of end of a pair
of brackets, that bracket and it's partner are highlighted - good stuff
for bug-fixing! So... there is a .emacs file here
(currently called emacs_file) - just download it and save it in
your root directory as .emacs (first backing up your existing .emacs
file!!). Warning: this file works on the Sun UltraSparc on my desk. You
don't get all the features on an SGI, and no guarantees on other machines
- though you should get some or all of the features.
Running emacs without X windows:
This is useful for quick editing!
emacs -nw file.tex
Useful Links
Top
Last modified:
|
Copyright © 1999-2001 Jenny Williams
All Rights Reserved
|
Email: jenny@hep.man.ac.uk |