agenda using vi editor starting vi session command / input modes entering text editing text saving...

11
Agenda Using vi Editor Starting vi Session Command / Input Modes Entering Text Editing Text Saving vi Session Aborting Editing Session

Upload: theresa-chase

Post on 12-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Agenda Using vi Editor Starting vi Session Command / Input Modes Entering Text Editing Text Saving vi Session Aborting Editing Session

Agenda Using vi Editor

Starting vi Session Command / Input Modes Entering Text Editing Text Saving vi Session Aborting Editing Session

Page 2: Agenda Using vi Editor Starting vi Session Command / Input Modes Entering Text Editing Text Saving vi Session Aborting Editing Session

vi (Visual) Editor vi is a powerful, interactive, visually-

oriented text editor

Features: flexibility in performing various tasks ability to view many lines of text as opposed

to one line at a time possible to recover file edited by vi in the

event of a “system crash”

Page 3: Agenda Using vi Editor Starting vi Session Command / Input Modes Entering Text Editing Text Saving vi Session Aborting Editing Session

Starting vi Session There are two ways in order to start an

editing session with vi:

Enter vi filename (recommended since filename has already been assigned and changes will be saved to filename by enter ZZ while in vi).

Enter vi (filename is not assigned, therefore user has to type <ESC> :w filename <ENTER> and then enter ZZ to save file.

Page 4: Agenda Using vi Editor Starting vi Session Command / Input Modes Entering Text Editing Text Saving vi Session Aborting Editing Session

Modes There are two operational modes while

using the vi editor: Command Mode (default mode when

starting) Mode to allow user to give commands such as to

delete text, search for strings, search & replace, save changes, abort editing session without saving changes and exit the vi editor.

Input Mode Input Mode allows user to enter or edit text. If in

command mode press i to enter input mode.

Page 5: Agenda Using vi Editor Starting vi Session Command / Input Modes Entering Text Editing Text Saving vi Session Aborting Editing Session

Input Mode While in input mode, the input mode

indicator should appear as INPUT on the bottom of the vi screen.

If this indicator does not appear when you press i then type:

<ESC>:set showmode <ENTER> After typing or “inserting” text, type

<ESC> to return to Command Mode.

Page 6: Agenda Using vi Editor Starting vi Session Command / Input Modes Entering Text Editing Text Saving vi Session Aborting Editing Session

Entering Text Type in your text, but it is recommended

to press ENTER before the end of the line (i.e. do not use word-wrap). Also, do not use <SPACE> to end a line. Tilde “~” characters below text represent end of file.

Error Correction (As you type): CTRL-h Delete a letter CTRL-w Delete a word CTRL-u Delete a line

Page 7: Agenda Using vi Editor Starting vi Session Command / Input Modes Entering Text Editing Text Saving vi Session Aborting Editing Session

Editing Text You can move around to text in the

screen with the arrow keys while in Insert Mode.

For more advanced editing, you can return to Command Mode and use appropriate editing commands

Page 8: Agenda Using vi Editor Starting vi Session Command / Input Modes Entering Text Editing Text Saving vi Session Aborting Editing Session

Editing Commands(Within Command Mode)

Commands:

d Deletes current character dw Deletes to the end of the word dd Deletes the current line u Undo. “Undoes” the last

operation thatuser performed

Page 9: Agenda Using vi Editor Starting vi Session Command / Input Modes Entering Text Editing Text Saving vi Session Aborting Editing Session

Saving vi Session When you create a file using vi, all work

performed during vi session is stored in a Word Buffer (temporary storage) until the user saves their work.

When saving, changes in the work buffer are added to a new (empty) file if creating a new file, or changes in work buffer modify existing (previously created) file

Page 10: Agenda Using vi Editor Starting vi Session Command / Input Modes Entering Text Editing Text Saving vi Session Aborting Editing Session

Saving vi Session To save your vi session, you must

make sure you are in command mode by pressing <ESC>

To save your changes and exit, enter ZZ(i.e. two capital z’s)

Page 11: Agenda Using vi Editor Starting vi Session Command / Input Modes Entering Text Editing Text Saving vi Session Aborting Editing Session

Aborting Editing Session If you make a huge mistake in your

editing session (that undo cannot solve), you can abort your session without modifying the contents your file (dump the work buffer)

To abort the current editing session, press<ESC> :q! <ENTER>