Vi editor
Monday, April 20, 2009
Use vi editor
There are so many editors available with RedHat Linux distribution.You must know one
of them. We will learn and use vi editor in our classroom. To configure and maintain a
RedHat Linux system we must know the followings –
To create/edit a file with vi editor we use vi file_name command.
Press ‘I’ or ‘Insert’ button to insert contents to a file.
:wq - Save and Exit
:w - Save
:q - Quit
:x - Save and Exit
:se nu - Sets number of lines
/text - Searches a text
?text - Searches the text above the current position
yy - Yanking (Copy) line
No.yy - Copy lines (Replace No. with the number you want to copy)
dd - Delete line
p - Paste line
u - Undo changes
G - Go to the last line in the file
1G - Go to the first line in the file
!!command - Replace the blank line with the output of the command.
:1,$s/text/newtext/g - Search and Replace – text will be replaced by newtext throughout the document.
:8,12s/text/newtext/g - Find and Replace – between line 8 and 12
:.,.+10s/text/newtext/g - Replace between current line and next 10 lines
:r file_name - Read file_name and place it after the cursor.
:1,20w newfile - 1s t to 20t h line will be saved to newfile
:10,20w >> newfile1 - 10th to 20t h line will be appended to newfile1
There are so many editors available with RedHat Linux distribution.You must know one
of them. We will learn and use vi editor in our classroom. To configure and maintain a
RedHat Linux system we must know the followings –
To create/edit a file with vi editor we use vi file_name command.
Press ‘I’ or ‘Insert’ button to insert contents to a file.
Labels: editor.command, Linux, vi
Post a Comment