The vi editor - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

The vi editor

Description:

Some moving cursors. in the command mode. Beginning of the line. 0. End of the line. ... Cursor movement. Command. Customizing the vi environment: the set command ... – PowerPoint PPT presentation

Number of Views:104
Avg rating:3.0/5.0
Slides: 10
Provided by: HU00
Category:
Tags: cursors | editor

less

Transcript and Presenter's Notes

Title: The vi editor


1
The vi editor
  • CS240 Computer Science II

2
The three modes of vi Editor
3
Fucntions of the three mode in vi
  • Input mode allows text such as source code to be
    entered.
  • Command mode allows various commands to be
    entered for text editing and other purposes.
    Several commands such as insert, append, open,
    replace, and change that are issued in the
    command mode will take you to the input mode.
  • Last-line mode all commands that start with a
    colon puts vi in the last-line mode.
  • Note all text entered is temporarily kept in a
    buffer until permanently saved to disk.

4
Starting vi
Command Function
vi filename Create/edit filename starting a line 1.
vi n filename Edit filename starting a line n.
vi filename Edit filename starting last line.
vi -r filename Recover filename after a system crash.
5
Adding text filename from command to input mode
must press Escape key to return to command mode
Command Insert text
i Before the cursor.
I Before first non-blank character on line.
a After the cursor.
A At the end of the line.
o Open a line below the current line.
O Open a line above the current line.
6
Some moving cursors in the command mode
Command Cursor movement
Space, I, or ? Space to the right
H or ? Space to the left
w or W Word to the right or blank-delimited word to the right.
b or B Word to the left or blank-delimited word to the left.
End of the line.
0 Beginning of the line.
7
Miscellaneous Commands
Command Effect
w filename Store contents of buffer to filename.
q Quite vi.
q! Quite vi with saving contents of buffer.
Change upper case to lower case and vice versa.
ZZ Store content of buffer and quit vi.
f or CtrlG Displays the filename, the status,the current line number, the number of lines in the buffer, etc.
8
viewing different parts of the buffer in the
command mode
Command Cursor movement
Ctrl D Down (forward) one-half screen.
Ctrl U Up (backward) one-half screen.
Ctrl F Down (forward) one full screen.
Ctrl B Up (backward) one-full screen.
nG To line n or to the last line if without n.
H To the top of the screen.
M To the middle of the screen.
L To the bottom of the scren.
9
Customizing the vi environment the set command
  • In the command mode type set followed by a
    parameter listed below and press enter key.
  • all lists a complete list of parameters and
    their current status.
  • atuoindent (or ai) creates tab stops CtrlT tabs
    right and Ctrl_D tabs left. noautoindent or noai
    turns off autoindent feature.
  • shiftwidthnn sets the spacing (characters)
    between tab stops
  • number to display line numbers nonumber remove
    line numbers.
  • wrapmarginnn, where nn is arbitray positive
    integer representing characters after which
    wrap-around takes place.
  • showmode displays the mode type noshowmode
    removes the display.
  • Note that the parameters can be permanently set
    in a users startup file .profile With Bourne or
    Korn shell, or .login with C shell. The
    parameters may also be set in a .exrc file.
Write a Comment
User Comments (0)
About PowerShow.com