Essential shortcuts
M-: META key (ALT on most keyboards)
C-: CONTROL key
C-x C-f : open file
C-x b : switch to buffer
C-x k : kill buffer
C-s : search text forward
C-r : search text backward
C-+ / C– : Zoom in/out
C-space: mark set (start of the text to mark)
C-w: cut
M-w: copy
C-y: paste
Useful shortcuts
C-l : scroll to current line in the middle of the window
C-x 2 : split window horizontally
C-x 3 : split window vertically
Use of accents
M-x set-input-method latin-1-prefix
This will make accent characters combine with the following characters, so that you can type `” u’ to achieve `ü’, for example.
Interactively Find and Replace String Patterns on Multiple Files
We suppose all files are in the same folder.
- Open the folder:
- C-x d
- Mark the files to be included in the find/replace operation: m. To unmark files: u
- M-x dired-do-query-replace-regexp (or Q)
- to accept a replacement: y, to skip: n
- to accept for the whole file and move to next file: !
- to continue the query-replace if you fall out of the loop:
- M-, (i.e. Meta-comma)
- to save all modified buffers (Emacs version > 22.2), show all buffers:
- M-x ibuffer
- select modified buffers: * u, save them: S (capital S)
- If you simply want to search for a regexp, use:
- M-x dired-do-search (or A)
- use M-, (Meta-comma) to loop through the results
Dired — marking files with similar pattern
Useful for example if you want to mark simultaneously all .tex files in a folder.
% m .tex$
(if you omit the $, .tex~ files will be marked as well)
Regexp
Insert a newline in a regexp or replacement string: CTRL-Q CTRL-J
Change coding system (between DOS and Unix)
DOS to Unix: C-x RET f undecided-unix
Unix to DOS: C-x RET f undecided-dos
Buffer coding system
In my case, the coding system that works when writing LaTeX files in Norwegian is iso-latin-1-unix. It’s the default when I create new .tex files, however, it may change when pasting text from e.g. my browser. The following commands revert to the right coding system:
C-x RET f iso-latin-1-unix