I am a heavy user of emacs, and as it's impossible to use all features of emacs I will list here some of what I use for personal reference and for others to pick up if it's of interest.
Note that for describing the keystrokes I use the common way of doing this for emacs where 'C' means 'ctrl' and 'M' (meta) means 'esc'.
As we use cvs at work this is something I use a lot. The starting
point here is the command M-x cvs-examine which lets you
select a directory of files where you can see the status of the files;
if they are modified or if they need to be updated and so on. Basically
it runs cvs -n up and displays it nicely. From within
this mode the bindings I use most frequently are:
| Key | Description |
|---|---|
f | Visits/Displays a file |
d e | Diffs a file against the repository where you easily can see and possibly revert your current changes. |
m | Mark file(s) |
c | Commit file or marked files |
e | Reexamines |
s | cvs status |
l | cvs log |
Other useful functions when working with cvs controlled files
are M-x vc-annotate that annotates the current buffer.
M-x compile is nice to be able to directly go to
compiler errors within emacs. One annoying thing with this mode is
that the compiler output do not scroll by default, but you can change
that by setting the variable compilation-scroll-output to
a non nill value. That can be set in your .emacs file like this:
(setq compilation-scroll-output t)
By default emacs starts up with no syntax highlighting and black text on white background. I prefer having a black background and of course syntax highlighting. Syntax highlighting is turned on using the not very obvious command global-font-lock-mode. Make sure that is always on using in your .emacs:
(global-font-lock-mode t)
To use black background instead of white add this:
(set-foreground-color "white") (set-background-color "black")
For long coding sessions I have found that yellow on black is what I like best. There is a library for different color themes to use that is called color-theme where I use the theme goldenrod for my yellow on black theme. I am sure you can find another theme you like there. I use the following to set that up:
;; ColorTheme (require 'color-theme) (color-theme-initialize) (color-theme-goldenrod)
You can read more about color-theme here.
To be able to work efficiently it's vital that you are able to
search from within the editor. C-r
and C-s are the two most simple commands for searching
for a text string in the buffer you are currently editing. They search
backwards and forwards respectively. The same commands are available
for regexp searching as well, but usually the normal ones work
fine.
Searching for strings in files recursively in the directory of your
current buffer from within emacs can be done using the
command grep-find.
Search and replace is of course also a common function to use. You
can do this by M-%.
This is a very useful function that I use often for make a lot of similar changes where a search and replace using a regexp simply will be too complicated. It just records your keystrokes and then you can replay them once or a specific number of times.
To start recording a macro use C-x ( and when done
with your typing you use C-x ). To replay your
keystrokes use C-x e. To replay them a specified
number of times use M-number where number is a
number like 32. By the way the M-number command is not
specially bound to macros, you can use it in front of most commands to
repeat that command a number of times. For example you can just
try M-45 j and 45 j's will be entered in the buffer.
Editing files remotely can be very convenient. Emacs provides a way
of doing this by a functionality called tramp. It's used in
the following way. Use C-x f for the
standard find-file command and start entering the filename
like this…
/username@ftp.somewhere.fi:
… if you are going to edit a file over ftp at ftp.somewhere.fi. Press tab at the ':' and you should be asked for the login password. When you are connected you can start autocompleting for files at the remote server. Then everything works like normal. If the connection times out you will be automatically logged in again when trying to save the buffer.
To be written... (how to add --exclude='*~' to grep-find)(tramp)