PHP.ph

26 Jul, 2008

Unix Visual Editor: Basic vi Commands

Posted by: php In: Unix

Visual Editor – vi is used to edit files through SSH. It is the default text editor that comes with a UNIX system.

To start vi
vi filename

Two Modes

Insert mode
press i
i

Command mode
press Esc
Esc

Saving

Save
:w

Save and quit
:wq
ZZ

Save as
:w newfilename
:w phpinfo.php – save as phpinfo.php

Quit without saving
:q!

Moving the Cursor

Move left, one character
h
left arrow

Move right, one character
l
right arrow

Move down, one line
k
down arrow

Move up, one line
h
up arrow

Move to last column on the current line
$

Move to first column on the current line
0
zero not letter o

Move back to the begining of the previous word
b

Move forward to the beginning of the next word
w

Move forward to the end of next word
e

Move up one paragraph
{

Move down one paragraph
}

Undo
u

Finding a Word or String

Find a word going backward
?
?linux - finds the word linux, backward direction

Find a word going forward
/
/linux - finds the word linux, forward direction

Move to next occurrence of the word
n

Move to next occurrence of the word, opposite direction
N

Copying and Pasting

Copy
yy

Paste after the current line
p

Paste before the current line
P

Display current line number
^g
Ctrl g

Inserting / Insert Mode

Insert text before cursor
i

Append after cursor
a

Open and put text in a new line above cursor
O

Open and put text in a new line below cursor
o

Tags: ,

1 Response to "Unix Visual Editor: Basic vi Commands"

1 | PHP.ph » Centos 5: Installing XCache From Source

August 10th, 2008 at 6:37 am

Avatar

[...] Edit/Vi xcache.ini vi /etc/php.d/xcache.ini [...]

Comment Form

Categories

Links

PHP.ph is owned and managed, since 2002 by:
Dr. Jesus Lecitona
Visit his blogs about dentistry:
Denture
Dentures
Dental Implants Cost

About PHP.ph

Linux Apache MySQL PHP