本文发表在 rolia.net 枫下论坛Inserting Special Characters in Emacs
There are some characters that you cannot normally type into an Emacs buffer. For example, in a text file, you can specify a page break by inserting the formfeed character, ASCII C-l or octal code 014; when you print a file with formfeeds, the current page is ejected at this character and printing is resumed on a new page.
However, C-l has meaning as an Emacs command. To insert a character like this, use the quoted-insert function, C-q. It takes either a literal keystroke to insert, or the octal code of the character to insert. It inserts that character at point.
To insert a formfeed character at point by specifying its actual keystroke (C-l), type:
C-q C-l
To insert a formfeed character at point by specifying its octal character code, type:
C-q 014 [RET]
The preceding examples both do the same thing: they insert a formfeed character at point.
An interesting use of C-q is to underline text. To do this, insert a literal C-h character followed by an underscore (`_') after each character you want to underline.
To underline the character before point, type:
C-q C-h _
You can then use ul to output the text to the screen (see Underlining Text).
Another kind of special character insert you might want to make is for accented characters and other characters used in various languages.
To insert an accented character, use ISO Accents mode. When this mode is active, you can type a special accent character followed by the character to be accented, and the proper accented character will be inserted at point.
The following table shows the special accent characters and the key combinations to use. PREFIX... PLUS THIS LETTER YIELDS THIS RESULT
" a ä
" e ë
" i ï
" o ö
" u ü
" s ß
' a á
' e é
' i í
' o ó
' u ú
` a à
` e è
` i ì
` o ò
` u ù
~ a ã
~ c ç
~ d &dtilde;
~ n ñ
~ t &ttilde;
~ u ũ
~ < <<
~ > >>
~ ! &iexc;
~ ? &iques;
^ a â
^ e ê
^ i î
^ o ô
^ u û
/ a å
/ e æ
/ o ø
When a buffer contains accented characters, it can no longer be saved as plain ASCII text, but must instead be saved as text in the ISO-8859-1 character set (see Viewing a Character Chart). When you save a buffer, Emacs will notify you that it must do this.
To type the line `Emacs ist spa@ss'! in the current buffer, type:
M-x iso-accents-mode [RET]
Emacs ist spa"ss!
In the event that you want to type the literal key combinations that make up an accented character in a buffer where you have ISO Accents mode on, type the prefix character twice.
To type the text `'o' (and not the accent character ó) in a buffer while ISO Accents mode is on, type:
''o
NOTE: GNU Emacs has recently added a number of internationalization functions. A complete discussion of their use is out of the scope of this book; for more information on this topic, see `International Character Set Support' in The GNU Emacs Manual.更多精彩文章及讨论,请光临枫下论坛 rolia.net
There are some characters that you cannot normally type into an Emacs buffer. For example, in a text file, you can specify a page break by inserting the formfeed character, ASCII C-l or octal code 014; when you print a file with formfeeds, the current page is ejected at this character and printing is resumed on a new page.
However, C-l has meaning as an Emacs command. To insert a character like this, use the quoted-insert function, C-q. It takes either a literal keystroke to insert, or the octal code of the character to insert. It inserts that character at point.
To insert a formfeed character at point by specifying its actual keystroke (C-l), type:
C-q C-l
To insert a formfeed character at point by specifying its octal character code, type:
C-q 014 [RET]
The preceding examples both do the same thing: they insert a formfeed character at point.
An interesting use of C-q is to underline text. To do this, insert a literal C-h character followed by an underscore (`_') after each character you want to underline.
To underline the character before point, type:
C-q C-h _
You can then use ul to output the text to the screen (see Underlining Text).
Another kind of special character insert you might want to make is for accented characters and other characters used in various languages.
To insert an accented character, use ISO Accents mode. When this mode is active, you can type a special accent character followed by the character to be accented, and the proper accented character will be inserted at point.
The following table shows the special accent characters and the key combinations to use. PREFIX... PLUS THIS LETTER YIELDS THIS RESULT
" a ä
" e ë
" i ï
" o ö
" u ü
" s ß
' a á
' e é
' i í
' o ó
' u ú
` a à
` e è
` i ì
` o ò
` u ù
~ a ã
~ c ç
~ d &dtilde;
~ n ñ
~ t &ttilde;
~ u ũ
~ < <<
~ > >>
~ ! &iexc;
~ ? &iques;
^ a â
^ e ê
^ i î
^ o ô
^ u û
/ a å
/ e æ
/ o ø
When a buffer contains accented characters, it can no longer be saved as plain ASCII text, but must instead be saved as text in the ISO-8859-1 character set (see Viewing a Character Chart). When you save a buffer, Emacs will notify you that it must do this.
To type the line `Emacs ist spa@ss'! in the current buffer, type:
M-x iso-accents-mode [RET]
Emacs ist spa"ss!
In the event that you want to type the literal key combinations that make up an accented character in a buffer where you have ISO Accents mode on, type the prefix character twice.
To type the text `'o' (and not the accent character ó) in a buffer while ISO Accents mode is on, type:
''o
NOTE: GNU Emacs has recently added a number of internationalization functions. A complete discussion of their use is out of the scope of this book; for more information on this topic, see `International Character Set Support' in The GNU Emacs Manual.更多精彩文章及讨论,请光临枫下论坛 rolia.net