Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

vi change Commands

Expert Oracle Database Tips by Donald BurlesonMarch 22, 2015

Making and Undoing Changes

There are a lot of ways to change, remove or replace text in vi.  The following commands allow specific changes to be made, and perhaps most useful, undo changes that have been made.

Command Action
x Delete one character
r Replace one character with the next character typed
dw Delete from the cursor position to the end of the current word
dd Delete the current line
D Delete from the current character to the end of this line
cw Same as dw then enter insert mode
cc Clear the text on this line and enter insert mode
C Delete from the current cursor position to the end of the current line and enter insert mode
J Join the next line to the current line
u Undo the last change.  Can be repeated to undo the past several changes.
. Repeat the last edit command at the current cursor position

Table 3.4:  Commands for Changing Text and Undoing Changes

Like the cursor movement commands, many of these commands can be preceded with a number to repeat the given command.  Even the undo comman can be preceded by a number to undo several recent commands.

Copying and Pasting

vi offers many options for copying and pasting including the ability to copy and paste from multiple buffers (a buffer is similar to the clipboard in Windows or Mac OS), but the basic copy and paste commands will only be touched upon.  The following commands allow you to copy and paste.

Command Action
yy Copy the current line into the default buffer
7yy Copy the current line plus the next six lines to the default buffer
p Paste the contents of the default buffer below the current line
P Paste the contents of the default buffer above the current line

Table 3.5:  Common Copy and Paste Commands

If multiple lines are copied with the yy command, the number of lines does not need to be specified when pasting.  The paste commandautomatically pastes the entire contents of the default buffer.

Searching and Replacing

Searching for text and replacing text in vi can be very handy, but it is not as easy as you might think!  Here are some of the more useful search and replace commands in vi: 

Command Action
/search text Find and move the cursor to the next occurrence of search text
'search text Find and move the cursor to the previous occurrence of search text
n Repeat the last search
N Repeat the last search but in the opposite direction (previous occurrence instead of next or next occurrence instead of previous)
:%s/search text/replace text/g Find all occurrences of search text and replace it with replace text
:noh Turn off highlighting of searched for text

Table 3.6:  Some Search and Replace Commands

When these commands encounter the end of the file, they wrap around to the beginning and continue searching.  If searching backwards, they wrap from the beginning to the end.  It has probably been noticed that the find and replace command is very complicated.  There are ways of making it even more complicated and having it search only specific lines, but that level of complexity is not particularly needed.

Saving and Exiting

Work should be saved often and when all is done, exit vi.  As with other things in vi, there are several ways to save and exit.  Here are a few common ones:

Command Action
:w Save changes
:w filename.txt Save changes to filename.txt instead of the file opened
:q Exit vi (changes should have already been saved)
:q! Exit vi without saving changes
:wq Save changes and exit vi
ZZ Save changes and exit vi (same as :wq)
:w! Write changes despite read-only permissions (must be file owner)

Table 3.7:  Commands for Saving and Exiting in vi

This short section is only a brief introduction to vi, but it should be enough to do basic editing and some shell scripting.  vi allows text to be manipulated in just about any way imaginable, so if there is something specific that is to be done in vi, take a look through the help documents available by entering :help within vi or in an easier-to-navigate form on the Web at http://vimdoc.sourceforge.net.

 

 

 
 
 
Get the Complete Details on
Linux System Management for Oracle DBAs  


The landmark book "Linux for the Oracle DBA: The Definitive Reference" provides comprehensive yet specific knowledge on administering Oracle on Linux.   A must-have reference for every DBA running or planning to run Oracle on a Linux platform.

Buy it for 30% off directly from the publisher.
 


 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster