Wednesday, August 6, 2008

VI Unix editor

Oracle Certification Program Candidate Guide



The vi editor is a shell editor for Unix systems. It makes use of a regular keyboard with an Escape key. On a DEC station the Escape key is the F11 key. It works on all Unix computers. Use a Telnet or SSH client and login to your web server. Enter your username and password, then type

su -

at the command line. Enter your root password to get access to root.

Complete documentation is available by typing: man vi


START SESSION

vi filename - filename is the file to be edited

UNDO

u - undo the last command


SCREEN COMMANDS
(CTRL-X means pressing the CTRL key and the X key simultaneously)

CTRL-l - reprint current screen

CTRL-L - expose one more line at the top of the screen

CTRL-E - expose one more line at the bottom of the screen

CTRL-F - go forward one screen

CTRL-B - go back one screen

CTRL-D - page down half a screen

CTRL-U - page up half a screen


CURSOR POSITIONING COMMANDS

j - move cursor down one line, same column

k - move cursor up one line, same column

h - move cursor back one character

l - move cursor forward one character

RET - move cursor to beginning of next line (RET is the Return key)

0 - move cursor to beginning of current line

$ - move cursor to end of current line

SPACE - move cursor forward one character (SPACE is the Space bar)

nG - move cursor to the beginning of line n (Default is the last line of the file)

:n - move cursor to the beginning of line n

b - move the cursor backward to the beginning of the previous word

e - move the cursor backward to the end of the previous word

w - move the cursor forward to the next word

/pattern - move cursor forward to the next occurrence of a pattern

?pattern - move cursor backward to the next occurrence of a pattern

n - repeats the last / or ? pattern search.


TEXT INSERTION COMMANDS

a - append text after the cursor (press ESC key to terminate the command)

A - append text at the end of the line (press ESC key to terminate the command)

i - insert text before the cursor (press ESC key to terminate the command)

I - insert text at the beginning of the line (press ESC key to terminate the command)

o - open a new line below the current line for text insertion (press ESC key to terminate the command)

O - open a new line above the current line for text insertion (press ESC key to terminate the command)

DEL - overwrite the last character during text insertion (DEL is the Delete key)

ESC - stop text insertion. (ESC is the Escape key, on a DEC station this is the F11 key)


TEXT DELETION COMMANDS

x - delete the current character

dd - delete the current line

dw - delete the current word

d) - delete the rest of the current sentence

D or d$ - delete from cursor to end of line

P - put text back from previous delete


TEXT MODIFICATION COMMANDS

cw - change characters of current word (until terminated with the ESC key)

c$ - change text up to the end of the line

C or cc - change remaining text on current line (until terminated with the ESC key)

~ - change case of the current character

xp - transpose current and following characters

J - join current line with next line

s - delete the current character and go into insertion mode

rx - replace the current character with x

R - replace the following characters (until terminated with the ESC key)


CUT AND PASTE COMMANDS

yy - put the current line in a buffer (does not delete the line from its current position)

p - places the line in the buffer after the current position of the cursor


APPEND FILE COMMANDS

:R filename - insert the file filename where the cursor was before the : was typed


EXIT COMMANDS

ZZ - exit vi and save changes

:wq - write changes to current file and quit editing session

:q! - quit editing session (no changes are made)

No comments:

Search

My Blog List