Enquiry : Mr.Jason Chan (mwchan@phy.cuhk.edu.hk, Rm348)
Invoke EMACS : > emacs filename
Most emacs comands can be invoked by pressing Control Key + a letter OR Alternate Key + a letter, for example, [Ctrl+y] means holding the control key & press y. Belows are some important commands :
Cursor Movement :
Delete Text :
Search/Replace Text :
Invoke PICO : > pico filename
Basic Commands :
Invoke VI : > vi filename
Objectives
vi
Cursor Movement
From command mode
+--------+--------------------+ | h | left, one space | +--------+--------------------+ | j | down, one line | +--------+--------------------+ | k | up, one line | +--------+--------------------+ | l | right, one space | +--------+--------------------+ | ^ | beginning of line | +--------+--------------------+ | $ | end of line | +--------+--------------------+ | 1G | first line | +--------+--------------------+ | G | last line | +--------+--------------------+ |[CTRL]f | forward one screen | +--------+--------------------+ |[CTRL]b | backward one screen| +--------+--------------------+ |[CTRL]d | down half screen | +--------+--------------------+ |[CTRL]u | up half screen | +--------+--------------------+
From command or text mode
<esc> get to command mode
Create a File
Insert and Delete
a - append or add text
- change the editor to text input mode
- a will not be displayed
d$ - delete from cursor to end of line
dd - delete the entire line
ndd - delete n lines
dw - delete to the end of the word
i - insert text before cursor
o - open a new line after cursor
O - open a new line before cursor
p - put item last deleted before current line
P - put item last deleted after current line
rx - replace current character with x
x - delete 1 character at the cursor position
Save / Exit a File
< esc > - change the editor to command
mode
:q! - exit without saving
:w - write the editing buffer to the file
:wq - write and exit vi
ZZ - save & quit
String Search
/the/ - put the cursor on the first
occurrence of the string the
?the?- similar to /the/ but in opposite
direction
n - search next occurrence of the string
N - similar to n but in opposite direction
Global Search and Replace
Example :Replace every if with if and only if
:g/ if /s// if and only if /g
Undo
:u - allow command to
appear on screen
u - command will not
appear anywhere on
the screen
. - repeat last command
Environment Customization
:set all
:set nu
:set noshowmode
.exrc File
Crash Recovery
vi -r filename
vi -r
Compose a LaTeX source file to DVI format : > latex myfile.tex
(Then, a file "myfile.dvi" will be generated)
Transform a DVI file to Postscript file : > dvips myfile.dvi
(Then, a file "myfile.ps" will be genrated)
Print a Postscipt file : > lpr -Plj326 myfile.ps
(Attention : only lj326, lj328 & lj204 support postscript format)
For more details about how to write a LaTeX source file, please refer to the user's guide & reference manual of LaTeX. You can borrow the book from Mr.Jason Chan.
If you are using the terminal of anyone of the DEC workstations, you can invoke a X-window base text editor "dxnotepad" on the command line.
If you are using the terminal of anyone of the SUN workstations, you can invoke a X-window base text editor "textedit" on the command line.