9
CS 497C – Introduction to UNIX Lecture 18: - The GNU emacs Editor Chin-Chih Chang [email protected]. edu

CS 497C – Introduction to UNIX Lecture 18: - The GNU emacs Editor Chin-Chih Chang [email protected] [email protected]

  • View
    216

  • Download
    2

Embed Size (px)

Citation preview

Page 1: CS 497C – Introduction to UNIX Lecture 18: - The GNU emacs Editor Chin-Chih Chang chang@cs.twsu.edu chang@cs.twsu.edu

CS 497C – Introduction to UNIXLecture 18: - The GNU emacs

Editor

Chin-Chih [email protected]

Page 2: CS 497C – Introduction to UNIX Lecture 18: - The GNU emacs Editor Chin-Chih Chang chang@cs.twsu.edu chang@cs.twsu.edu

Deleting, Moving and Copying Text

• To delete a character, use [Ctrl-d]. To delete a word, use [Alt-d].

• To delete text from the current cursor position to the end of line, use [Ctrl-k].

• To delete the entire line, first use [Ctrl-a] and then [Ctrl-k][Ctrl-k].

• To delete text in a region, first mark the region and then use [Ctrl-w].

Page 3: CS 497C – Introduction to UNIX Lecture 18: - The GNU emacs Editor Chin-Chih Chang chang@cs.twsu.edu chang@cs.twsu.edu

Deleting, Moving and Copying Text

• [Ctrl-y] is universally used to restore text from the deletion.

• While [Ctrl-w] deletes text in a region, the command to copy text is [Alt-w].

• You can transpose two adjacent characters by using [Ctrl-t].

Page 4: CS 497C – Introduction to UNIX Lecture 18: - The GNU emacs Editor Chin-Chih Chang chang@cs.twsu.edu chang@cs.twsu.edu

Changing Case of Text

• To convert an entire word to uppercase, move to the beginning of the word and then press [Alt-u].

• You use [Alt-u] for converting a word to lowercase.

• To capitalize a single character, position the cursor under it and then use [Alt-c].

Page 5: CS 497C – Introduction to UNIX Lecture 18: - The GNU emacs Editor Chin-Chih Chang chang@cs.twsu.edu chang@cs.twsu.edu

Changing Case of Text and Command Completion

• For transforming case in large blocks of text, use a region. The commands to convert text in a region are: [Ctrl-x][Ctrl-u] and [Ctrl-x][Ctrl-l].

• The command completion feature can reduce some of the typing work.

• The guiding principle here is this: Enter as much of the command text as you want and then press the [Tab] key.

Page 6: CS 497C – Introduction to UNIX Lecture 18: - The GNU emacs Editor Chin-Chih Chang chang@cs.twsu.edu chang@cs.twsu.edu

Undoing and Redoing Editing

• To undo the change, there are three ways: [Ctrl-x]u, [Ctrl-_], [Ctrl--].

• If you continue to press [Ctrl--], you’ll undo the changes made before the last save.

• If you keep pressing [Ctrl--], emacs starts redoing everything that you have undone.

Page 7: CS 497C – Introduction to UNIX Lecture 18: - The GNU emacs Editor Chin-Chih Chang chang@cs.twsu.edu chang@cs.twsu.edu

String Search

• The incremental and non-incremental search techniques are used in string search in emacs.

• Incremental search is invoked with [Ctrl-s] followed by the search string.

• After entering [Ctrl-s] emacs prompts for the search string in the minibuffer. Suppose you’re looking for mail. After m is entered, the search starts immediately.

Page 8: CS 497C – Introduction to UNIX Lecture 18: - The GNU emacs Editor Chin-Chih Chang chang@cs.twsu.edu chang@cs.twsu.edu

String Search

• The cursor relocates itself at the first instance of m – maybe on the word moon.

• After mail is entered, press [Enter].

• There are a number of advantages of using incremental search:– The search is faster.– emacs tells you instantly whether the string

exists in the file.– If there is a typo, backspacing erases the error.

Page 9: CS 497C – Introduction to UNIX Lecture 18: - The GNU emacs Editor Chin-Chih Chang chang@cs.twsu.edu chang@cs.twsu.edu

String Search• At the end of a file, use [Ctrl-r] instead of

[Ctrl-s].• To repeat a search, you’ll have to use the

same command – [Ctrl-s] or [Ctrl-r].• In non-incremental search just press [Enter]

and then type the string.• Like vi, emacs uses a pattern comprising

some special characters to look for similar strings. This pattern is called a regular expression.