| UNIX Text Editors |
 |
 |
There are several text editors that create plain text files, such as emacs, vi and pico. Unless you are already familiar with vi or pico, we recommend that you use EMACS (Editor MACroS), known simply as emacs. We strongly recommend that you study the emacs tutorial, which you can easily start in any empty session.
In emacs you use combinations of special keys and character keys to invoke commands. The commands usually involve either the CONTROL key (CTRL or CTL) or the META key (ESC on MAC or ALT, EDIT on others). Therefore, Ctrl-h (or C-h) means that you press the CONTROL and h key together, while Ctrl-h t (C-h t) means that you press the CONTROL and h keys, then release both keys and tap t.
To start the emacs tutorial:
Ctrl-h t
To get help in emacs:
Ctrl-h
To exit emacs, type:
Ctrl-x-c
To exit an emacs command, type:
Ctrl-g
For an emacs Command Summary open this link
Creating and Editing Files
To open and edit a file in emacs, simply type
emacs myfile (my file can be a new or an existing file)
To save a file:
Ctrl-x-s
To choose a file from the current directory:
Ctrl-x-f (type '.'-ENTER in dialog box at bottom of window)
To move within your file in emacs:
previous line Ctrl-p
next line Ctrl-n
backward 1 char Ctrl-b
forward 1 char Ctrl-f
backward 1 word Meta-b
forward 1 word Meta-f
To navigate by page and file:
forward one page Ctrl-v
backward one page Meta-v
backward to start of file Meta-<
forward to end of file Meta->
Cut OR Copy & Paste Text
Very Important Command:
Undo last text edit Ctrl-x u
Complete lines of text:
Set cursor position to start of Cut or Copy
Set Mark Ctrl-space-bar
Cut text Ctrl-w
Copy text Meta-w
Reset cursor and paste text Ctrl-y
Blocks of text:
Set cursor position to start of Cut or Copy
Set Mark Ctrl-@
Move cursor across text and down to delineate rectangular area
Cut text Ctrl-x rk
Copy text Meta-x rk
Reset cursor and paste text Ctrl-x ry
To work with two files in two different emacs panes:
Split panes Ctrl-x 2
Move between panes Ctrl-x o
Cut, Copy & Paste as instructed above between 2 files
Replace Text Uniformly
Query for replace text in dialog box (prompt = Query replace: ) Meta-%
tap Enter
type replacement text (prompt = "Query replace with:")
tap Enter
Enter key for number of times to replace
! = replace every instance
space bar or y = replace one instance recursively
n to skip to next, q to exit, period to replace one match and exit
comma to replace but not move point immediately
Create Keyboard Macro
These are recorded keystrokes to automate text editing in emacs.
Start recording macro Ctrl-x (
tap a sequence of keystrokes
End recording of macro Ctrl-x )
Execute last macro in memory Ctrl-x e
Sample file for demonstration:
sample text file
|