[comp.unix.questions] quick introductions to editors

roberts@cmr.icst.nbs.gov (John Roberts) (07/27/88)

This is the only reply to my posting a few weeks ago that was not also
posted to the net:

----------------------------------------------------------------------
From tcs@USNA.MIL Wed Jul 13 16:27:58 1988
Return-Path: <tcs@USNA.MIL>
Received: from CAD.USNA.MIL by cmr.icst.nbs.gov (5.59/NBS-rbj4)
	id AA08474; Wed, 13 Jul 88 16:27:47 EDT
Received: by CAD.USNA.MIL id aa18721; 11 Jul 88 11:57 EDT
Date:     Mon, 11 Jul 88 11:29:30 EDT
From: Terry Slattery <tcs@USNA.MIL>
To: roberts@cmr.icst.nbs.gov
Subject:  Re: emacs vs vi
Message-Id:  <8807111129.aa18206@CAD.USNA.MIL>
Status: RO

I have quick introductions for both vi and jove (a version of emacs) which
help novice users get started.  I have enclosed both for your
enjoyment.  Please retain the acknowledgements on both.

	-tcs
---------
Jove Quick Intro.  We tell users that they only need 8 commands to use
jove.  1. saving changes, 2. exiting the editor, 3. left one char,
4. right one char, 5. up one char, 6. down one char, 7. delete one char,
and 8. that anything they type goes into the file.
---------
\"tbl jove.tb | troff -ms
.ND
.nr LL 6i
.ll 6i
.ce
\fBQuick Introduction To The JOVE Screen Editor\fR

.ce
T.C. Slattery, U.S. Naval Academy

\fBENTERING jove\fR
.TS
a l.
jove name	Start jove editor with filename.
.TE

\fBLEAVING jove\fR
.TS
a lw(4.75i).
CTRL-x CTRL-\e	T{
Saves your changes.  This should be done before exiting jove.  Note: this is 
two keystrokes.
T}
.TE
.br
.TS
a lw(4.75i).
CTRL-x CTRL-c	T{
Exits jove.  If your file has not been saved jove will ask if you really want 
to exit.  Answer 'y' if you don't want to save your changes; 'n' returns to 
jove to allow you to save your changes.
T}
.TE

\fBINSERTING TEXT\fR
.IP
Anything you type (except control characters) is inserted into jove's copy of 
your file.  The changes are saved by using the CTRL-x CTRL-\e command.

.br
.LP
\fBCURSOR POSITIONING\fR
.TS
a l.
CTRL-f	Moves forward one character position.
CTRL-b	Moves backward one character position.
CTRL-p	Moves to the previous line.
CTRL-n	Moves to the next line.
ESC f	Moves forward one word.
ESC b	Moves backward one word.
CTRL-v	Moves forward one page.
ESC v	Moves back one page.
CTRL-e	Moves to the end of the line.
CTRL-a	Moves to the beginning of the line.
ESC <	Moves to the beginning of the file.
ESC > 	Moves to the end of the file.
.TE

\fBTEXT MODIFICATION\fR
.TS
a lw(5i).
CTRL-d	Delete one character at the cursor position.
ESC d	Delete one word.
CTRL-k	T{
Delete (kill) the characters from the cursor position to the end of 
the line.
T}
CTRL-y	Put back what was just deleted at the current cursor position.
ESC q	T{
String replace. The following questions will appear: query-replace-search 
this<CR> Replace "this" with that<CR>  The cursor will then go to each 
occurrence of 'this' and change it to 'that' upon the response of the 
user.  (i.e. 'y' to replace, 'n' to skip, <CR> to quit, 'R' or 'r' to 
replace the rest of the occurrences without a prompt to the user.) 
T}
RUB or DELETE	Delete the previous character at the cursor position.
.TE

.br
\fBPATTERN\ SEARCHING\fR	
.TS
a lw(4.75i).
ESC s string	T{
Will find the next occurrence of string from the cursor position to the 
end of the file.
T}
.bp
ESC r string	T{
Will find the next occurrence of string from the cursor position to the 
beginning of the file (reverse search).
T}
.TE

\fBNOTES:\fR
.TS
a l.
ESC	Press the ESC key as a separate key stroke.
CTRL-	Hold the CTRL-key and press the following key simultaneously.
RUB & DELETE 	The RUBOUT or DELETE key on different terminals
CTRL-g	Will get you out of most hung up situations.
CTRL-q	Will restart output to your terminal if you accidentally press CTRL-s.
.TE

.ce
\fBAdvanced Editing with JOVE\fR

\fBCURSOR MOVEMENT:\fR
.TS
a lw(4.5i).
ESC f	move forward by words
ESC b	move backward by words
ESC num ESC g	T{
ESC followed by a number, then ESC-g moves to line number 'num'.  ESC 5 
ESC g moves to line # 5.
T}
CTRL-\e	Incremental forward search
CTRL-r	Incremental reverse search
.TE

\fBTEXT MODIFICATION\fR
.TS
a lw(4.75i).
ESC d	Delete the next word.
ESC delete	T{
Delete the previous word.  (Type ESC then press the DELETE or RUB key.)
T}
CTRL-w	Delete the previous word
CTRL-@	Move to the beginning of a region to delete, type
CTRL-x CTRL-k	T{
CTRL-@, move to the end of the region and type CTRL-x CTRL-k to delete the 
enclosed text
T}
.TE

\fBWINDOW COMMANDS\fR
.TS
a lw(5i).
CTRL-x 4	T{
Edit another file in a second window.  JOVE prompts for the second file name 
and automatically splits the screen.  The cursor is placed in the second 
window.
T}
CTRL-x o	Move the cursor to the other window.
CTRL-x 1	T{
Make the current window the only one. (delete other windows) (This is CTRL-x 
followed by the number 1.)
T}
CTRL-x 2	T{
Split the screen into two windows.  Useful for simultaneously viewing two 
portions of a file
T}
.TE

\fBMISCELLANEOUS\fR
.TS
a lw(5i).
CTRL-x CTRL-f	Edit another file without exiting JOVE.
CTRL-x CTRL-i	Insert the contents of another file at the current position.
ESC !	T{
Execute a Unix command and return to JOVE.  Note that this can be used to run 
a sub-shell.
T}
ESC x make	T{
Execute the 'make' program in a second window and capture the errors in that 
window.  Type two returns to start 'make'.  This lets one view the file and 
the compiler errors simultaneously.
T}
ESC j	T{
Justify the paragraph the cursor is in.  Default line width is 72 characters.
T}
CTRL-y	Restore text inadvertently deleted.
.TE


------------------
Vi QI.  This one was one we made before getting Jove.  Since it is
modal for lots of operations, we find it less easily learned by complete
novices.  The Jove QI used to have a layout like this, but the
person who now administers the stuff decided to use troff and the page
layouts are not quite right.  The ideal is basic commands and notes on
the first page and advanced commands on the back.
---------------------
	QUICK INTRODUCTION TO THE vi VIDEO EDITOR
		T.C. Slattery, US Naval Academy

ENTERING vi

	vi name		start vi editor with file   name   .
			The file is created if it doesn't exist.

LEAVING vi

	ZZ		exit from vi, saving changes.
	:q!		exit from vi, discarding changes.

CURSOR POSITIONING

	h		moves left one character position.
	j		moves down one line.
	k		moves up one line.
	l		moves right one character position.
			 NOTE: On the adm3a video terminal keyboard, these
			  letters have arrows above them which correspond
			  to the direction of the cursor movement.
	0	(zero)	moves to the beginning of a line.
	w		moves right one word.
	b		moves left one word.
	CTRL-u		moves up 1/2 screen full.
	CTRL-d		moves down 1/2 screen full.
	G		moves to the bottom of the file.
	nG		moves to line number   n   .
	CTRL-l		clear screen and re-draw.

TEXT MODIFICATION

	itextESC	inserts   text   to the left of the cursor.
			 Insert doesn't cause the cursor to move;  text
			 appears as it is typed, terminate with ESC.
	atextESC	appends  (inserts)   text   to the right of the
			 cursor, terminate with ESC.
	RtextESC	Replaces (overprints) characters at the cursor
			 position, terminate with ESC.
	dd		deletes the line the cursor is on.
	ndd		deletes   n   lines from the cursor position.
			 NOTE: Deleted lines are replaced with the character
			   @   which is removed when the page is re-drawn.
	D		deletes characters from the cursor position to the
			 end of the line.
	x		deletes the character at the cursor.
	nx		deletes   n   characters to the right of the
			 cursor.
	u		undo the last change.

PATTERN SEARCHING

	/pat/		positions the cursor at the next occurrence
			 of the string   pat   .

NOTES:
	ESC	represents the ESC key.  Press the ESC key when it is
		called for in the above commands.
	CTRL-	represents the CTRL key.  Hold the CTRL key and press the
		following key simultaneously.

------------------
Second page of vi QI
---------------------
	SECOND LEVEL vi EDITING COMMANDS

CURSOR POSITIONING

	}		move down one paragraph.
	{		move up one paragraph.
	mx		save the current cursor position and label it
			with the letter x. (x is any letter)
	'x		return to the cursor position labeled x.

TEXT MODIFICATION

	dw		delete the next word.
	.      (period) repeat last change.
	A		append at the end of the current line.
	P		put back deleted line(s).  Text deleted with D
			and dd commands may be pasted back with the P
			command.  Text is pasted in before the cursor
			position.
	:a,bs/old/new/	From line number 'a' to line number 'b', substitute
			the pattern 'old' with the pattern 'new'.  You
			may use any text string which doesn't contain a
			carriage return in place of the 'old' and 'new' 
			strings.  Use CTRL-G to tell what line the cursor is
			on.
PATTERN SEARCHING

	//		search for the next occurrence of a previously
			specified search string.  

MISCELLANEOUS

	:w		write out current changes.  The vi editor works
			on a copy of your file.  The :w command causes
			the editor to write its copy over the original
			which is on the disk.
	:w name		write out changes to the file  name  .  This is
			like the :w command but the changes are written
			into the file you specify.  (good for making
			intermediate copies)
Cut and Paste		Move to the begining of the text to cut.  Use dd
			to delete (cut) several lines.  Use D to cut only
			the end of one line.  Move to the place where you
			wish to paste the text.  Use P to put back the text.
			You may need to clean up the spacing after pasting.




 ---------------------------------------------------------------------------
                                            John Roberts
                                            roberts@cmr.icst.nbs.gov