CentOS Linux Server Guide

Vi Editor - Cut and Paste and Undo Text or Sentences Using Keyboard

Cutting and past text is not an easy job unless you internalized some of the common keys below.

 
Keyboard  Operation
x  delete current character
Nx  N refer to number, delete the number of character(s) from the right
X  delete the character left to the cursor
dd  delete the entire line where position of the cursor located
d$  delete all the lines that from where the cursor is to the end of line
d^  delete all the lines from beginning until where the position of the cursor.
yy  copy current line
Nyy  N refer to number, copy the current and the N number of lines next to it
p  paste to the position next the cursor
u  undo your operation

 

Example

In the following example, you will open up the mail.log and go the 2nd line of the file
vi mail.log +2

 

Read more on Visual Editor (VI)



Copyright 2011 http://www.1a-centosserver.com All Rights Reserved

All trademarks are the property of their respective owners.

Contact Us | Terms of Use | Privacy Policy