Oracle DBA Guide

Handy commands while using vi editor

You might find following commands handy while working with vi Editor.


1. Write to a New File 


You can use :w to save an entire buffer (the copy of the file you are editing) under a new filename


:w new_file1


2. Saving part of the file (1 to 20 lines of the file to new file newfile2


:1, 20 w newfile2


3. From line 230 to end of the file would be saved to newfile3


:230,$ w newfile3


4. From current line to line 600 is saved to newfile4


:.,600 w newfile4   Note the dot which indicates current


5.  Substitute


First character on 1 to 10 lines would be  replaced by word  “create user” .

:1,10s/^/create user /


To download FREE first 3 chapters of “Unix Handbook for Oracle DBA and for DBA Tips

Enter Your E-mail Address
Enter Your First Name (optional)
Then

Don't worry — your e-mail address is totally secure.
I promise to use it only to send you Oracle DBA FREE Downloads and Tips.


6.  To append to existing file


You can use the UNIX redirect and append operator (>>) with w to append all or part of the contents of the buffer to an existing file. For example, if you entered:


:1,10w newfile


and then:


  :340,$w >>newfile


newfile would contain lines 1-10 and line 340 to the end of the buffer.


7.   To insert a character or Change the word

i

    insert

cw

   change word


8.  Wipe out all changes


What if you want to wipe out all of the edits you have made in a session and then return to the original file? The command:


:e! [RETURN]


returns you to the last saved version of the file, so you can start over.


9.  Saving into existing file:


Type :w! file to overwrite the existing file, or type :w newfile to save the edited version in a new file.


Insert text                              i any text you like

Return to command mode      [ESC]

Quit vi, saving edits                  ZZ


10.  Single Movements within command mode in vi editor


The keys h, j, k, and l, right under your fingertips, will move the cursor:

h


    left, one space.

j


    down, one line.

k


    up, one line.

l


    right, one space.

...


Continue toI/O Redirectors: Standard Input and Standard Output


To download FREE copy of “Recover Database 10 times Faster E- Book” and for DBA Tips

Enter Your E-mail Address
Enter Your First Name (optional)
Then

Don't worry — your e-mail address is totally secure.
I promise to use it only to send you Oracle DBA FREE Downloads and Tips.
For More Practical Tips, Commands and Scripts on Unix

Click  The Practical guide to Unix Commands and Tips for Oracle DBA’s and Developers



To Learn the Untold Secrets of a Professional DBA that Separates you from the Rest

Click  Best kept secrets of database Restore and Recovery

+1 demo: Basic page

New! Comments

>" comments have already been left on this page. Have your say about what you just read! Leave me a comment in the box below."






For FREE Book about

Living your dreams and Live a fulfilled life

Click Live your Dreams




Best Kept Secrets of Database Restoration

(Oracle 11g R2)














Untold Secrets of an Expert DBA

Click










Master the art of Oracle Database Restore and Recovery

Click









Uncover the Practical Tips on Real Application Cluster (Oracle 10g)

Click