Apache Awk Bash C cftp daemontools DHCP djbdns DNS Emacs Email ezmlm Fetchmail find GDB Hardware HTML HTTP Intro ISDN less Make Math mc mirrordir MySQL Peripherals Perl PHP3 pppd qmail Regexps Shell System Tables test To do Typical ucspi-tcp Versions Index TCP/IP slides

Usefull command sequences

Command sequences
M-x delete-trailing-whitespace To delete all white space at the end of all lines in the buffer
C-x C-f /username@hostname:/path_to_file To directly edit a ftp-able file
C-x C-w path_to_file To write the current buffer to a new file
M-C-r regexp Interactive search backwards by regexp
M-C-s regexp Interactive search forward by regexp
C-u C-x ( Continue defining current keyboard macro
M-x shell Enter shell mode
C-x n n Narrow to region
C-x n w Widen to full buffer
M-d Delete word
C-x l Count lines, total, before and after point

HTML and SGML mode

HTML and SGML mode
C-c C-f
or
C-c right
Forward tag or element
C-c C-b
or
C-c left
Backward tag or element
C-c C-d
or
C-c backspace
Delete tag (both starting and ending tags)
C-c ? Short help on tag
C-c 8 Toggle 8 bit mode ( á written as á)
C-c C-a Interactive insert of attributes on tag
C-c C-t Prompts for tag and inserts it
C-c TAB Toggles visibility of tags
C-c C-v Shows buffer trough browser
C-c C-n Next char inserted by name ( C-c C-n < gives &lt;)
C-c C-j Inserts <br>
C-c RET Inserts <p>
C-c 1 Inserts <h1></h1>
C-c 2 Inserts <h2></h2>
C-c 3 Inserts <h3></h3>
C-c 4 Inserts <h4></h4>
C-c 5 Inserts <h5></h5>
C-c 6 Inserts <h6></h6>
C-c C-c i Inserts <img src="">
C-c C-c n Inserts <a name=""></a> and prompts for anchor
C-c C-c h Inserts <a href=""></a> and prompts for href
C-c C-c l Inserts <li>
C-c C-c c Inserts successive checkbox inputs, prompting for attributes
C-c C-c r Inserts successive radio inputs, prompting for attributes
C-c C-c u Inserts skeleton for <ul></ul>
C-c C-c o Inserts skeleton for <ol></ol>
C-c C-c - Inserts <hr>

Shell-script mode

Shell-script mode
C-c C-c case statement
C-c C-f for loop
C-c ( function definition
C-c TAB if statement
C-c C-l indexed loop from 1 to n
C-c C-o while getopts loop
C-c C-r repeat loop
C-c C-s select loop
C-c C-u until loop
C-c C-w while loop
C-j Delete unquoted space and indent new line same as this one.
M-e Go to end of successive commands.
M-a Go to beginning of successive commands.
C-c : Set this buffer's shell, and maybe its magic number.
M-C-x Pass optional header and region to a sub-shell for non-interactive execution. The working directory is that of the buffer, and only environment variables are already set which is why you can mark a header within the script.
< Without prefix, following an unquoted < inserts here document.

Tags

Tags
M-. TAG Find first definition of TAG (`find-tag')
C-u M-. Find next alternate definition of last tag specified
C-u - M-. Go back to previous tag found
C-M-. PATTERN Find a tag whose name matches PATTERN (`find-tag-regexp')
C-u C-M-. Find the next tag whose name matches the last pattern used
C-x 4 . TAG Find first definition of TAG, but display it in another window (`find-tag-other-window')
C-x 5 . TAG Find first definition of TAG, and create a new frame to select the buffer (`find-tag-other-frame')
M-* Pop back to where you previously invoked `M-.' and friends
M-x tags-search REGEXP Search for REGEXP through the files in the selected tags table
M-x tags-query-replace REGEXP REPLACEMENT Perform a `query-replace-regexp' on each file in the selected tags table
M-, Restart one of the commands above, from the current location of point (`tags-loop-continue')
M-x list-tags FILE Display a list of the tags defined in the program file FILE
M-x tags-apropos REGEXP Display a list of all tags matching REGEXP
M-<TAB> Complete the partial symbol before point against the set of meaningful symbol names. Any additional characters determined by the partial name are inserted at point

Regexps

Regexps
. Matches any single character except a newline
* Postfix operator, match the preceding regular expression repetitively as many times as possible. (greedy, matches as much as possible)
+ Postfix operator, similar to * except that it must match the preceding expression at least once
? Postfix operator, similar to * except that it can match the preceding expression either once or not at all
[ ... ] "Character set", which begins with [ and is terminated by ]. To include character ranges in a character set use the starting and ending characters with a - between them. To include a ] in a character set, it must be the first character. To include a -, put - as the first or last character of the set, or put it after a range. To include ^ in a set, put it anywhere but at the beginning of the set
[^ ... ] [^ begins a "complemented character set", which matches any character except the ones specified. Thus, [^a-z0-9A-Z] matches all characters _except_ letters and digits. A complemented character set can match a newline, unless newline is mentioned as one of the characters not to match
^ Special character that matches the empty string, but only at the beginning of a line in the text being matched
$ Similar to ^ but matches only at the end of a line
\| Alternative. Two regular expressions A and B with \| in between form an expression that matches some text if either A matches it or B matches it. Applies to the largest possible surrounding expressions. Only a surrounding \( ... \) grouping can limit the grouping power of \|
\( ... \) Grouping construct that serves three purposes:
  1. To enclose a set of \| alternatives for other operations
  2. To enclose a complicated expression for the postfix operators *, + and ? to operate on
  3. To record a matched substring for future reference
\D Matches the same text that matched the Dth occurrence of a \(...\) construct \1 through \9 can be used to refer to the text matched by the corresponding \( ... \) constructs
\` Matches the empty string, but only at the beginning of the buffer or string being matched against
\' Matches the empty string, but only at the end of the buffer or string being matched against
\= Matches the empty string, but only at point
\b Matches the empty string, but only at the beginning or end of a word, or at the beginning or end of the buffer
\B Matches the empty string, but not at the beginning or end of a word
\< Matches the empty string, but only at the beginning of a word, and at the beginning of the buffer only if a word-constituent character follows
\> Matches the empty string, but only at the end of a word, or at the end of the buffer only if the contents end with a word-constituent character
\w Matches any word-constituent character. The syntax table determines which characters these are
\W Matches any character that is not a word-constituent
\sC Matches any character whose syntax is C. Here C is a character that represents a syntax code: thus, w for word constituent, - for whitespace, ( for open parenthesis, etc. Represent a character of whitespace (which can be a newline) by either - or a space character
\SC Matches any character whose syntax is not C

Registers

Registers
<register> represents any character
C-x r <SPC> <register> Save position of point in register <register>
C-x r j <register> Jump to position saved in register <register>
C-x r s <register> Save region in register <register>
C-x r i <register> Insert text from register <register> at point
C-x r n <register> Store 0 in register <register>
C-u <number> C-x r n <register> Store number in register <register>
C-x r + <register> Add 1 to value in register <register>
C-u <number> C-x r + <register> Add number to value in register <register>
C-x r g <register> Get value from register <register>

Rectangles

Rectangles
C-x r k Kill and save the text of the region rectangle
C-x r d Delete the text of the region rectangle
C-x r y Yank the text of the saved region rectangle
C-x r o Kill and save the text of the region rectangle

emacs invocation

Invocation
emacs +156 file
Open file and goto line 156
emacs -batch --no-site-file -f batch-byte-compile file.el
Batch compile file.el elisp file

elisp

elisp
; comment Comment format
(setq a 30) Assignment, this sets a to 30
(line-number-mode 't) Function call, this calls the function line-number-mode passing an argument of true (represented by 't)

.emacs

.emacs sample code
(define-key global-map [f19] 'qpoint-to-register)
(define-key global-map [f9] 'qjump-to-register)

(defun qpoint-to-register()
    "Store cursor position in a register
Use qjump-to-register to jump back to stored position"
  (interactive)
  (point-to-register 8)
)

(defun qjump-to-register()
    "Jumps to position stored with qpoint-to-register"
  (interactive)
  (jump-to-register 8)
)
This configures Shift-F9 to store the current location and buffer of the cursor (point)
F9 then returns point to that location and buffer
Last update: Wed, 2 Nov 2005 10:16:21 GMT