Emacs as Word Processor: Bold and Highlight Text
Perm url with updates: http://xahlee.org/emacs/emacs_as_word_processor.html
Emacs as Word Processor: Bold, Underline, Color Texts
Xah Lee, 2011-05-16
Jan from Oslo wrote and ask wouldn't it be great if emacs can be used as a word processor, i.e. letting users bold text, slant text, etc.
Yeah, i find that to be great. Imagine, i can just use it to write notes, with bold text, highlighted text, etc.
Note that emacs has a “facemenu-*” command. See the menu 〖Edit▸Text Properties▸Face〗. Here are the hotkeys.
- 【Alt+o d】 default
- 【Alt+o b】 bold
- 【Alt+o i】 italic
- 【Alt+o l】 bold-italic
- 【Alt+o u】 underline
- 【Alt+o o】 other
(See also: Emacs's Keybinding Layout.)
You can also use emacs's highlight commands to highlight text. e.g.:
Though, the problem is that when you save the file, the font decorations are not saved with it. So, in order to use make emacs to have word processor capabilities, you'll need a file format to go with it. Perhaps some soul has done it using one of the open source format such as html or rtf.
Anonymous wrote to say that the answer is “enriched-mode” minor mode. Thanks! Ask a emacs question and someone will have the answer!
So, i opened a new file, type 【Alt+x enriched-mode】, type “thou shall”, select the word “thou”, then use the menu 〖Edit▸Text Properties▸Face▸Bold〗 to make it bold, then save it, close it. Then reopen it, then indeed, the text is still bold.
“Enriched text” file format
Though, i wondered how it worked. So i opened the file in Notepad, and it shows this content:
Content-Type: text/enriched Text-Width: 80 <bold>thou </bold>shall
Ah, so it's a Enriched text format. This is a pretty old format, dating to early 1990s.
The features of the format is pretty minimal. You can bold, slant, underline, color, texts, but that's about it. Also, emacs's enriched-mode written originally in 1994.
Show File Raw Content
You can use emacs to show the file's raw content.
Here's a sample saved file: emacs_enriched_text_sample_file.txt.
Call “find-file-literally” then give the file path.
Also, if you create a file with the first line being
Content-Type: text/enriched, opening it in emacs automatically turns on the “enriched-mode” and interpret the file by that format for display.