Monday, November 7, 2011

VI editor (visual editor)

I would like to share my knowledge in different areas so this is about the VI editor. The VI editor I frequently used to edit files on Linux environments. , as I read this is available on many other operating systems, even on MS-DOS, Windows and the Macintosh as well.
I am experienced with VI editor in my tasks. Here I show very essentials details about VI editor that are very important to me.
This is somewhat a huge topic to be learnt and there are many details about VI editor. I also don't know many of VI editor features but I always search for them via internet, using these commands and get experience about VI editor and also try to learn from your experience as well.
VI is a powerful text editor which is most popular amongst Linux users in the world wide. The VI editor is a screen-based editor used by many Unix/Linux users. This is used as a powerful text manipulation and quick movement using only a keyboard.
The VI editor has powerful features to aid programmers, but many beginning users avoid using VI because the different features overwhelm them.
The first thing most users learn about the VI editor is that it has two modes:
1. Command
2. Insert
The command mode allows the entry of commands to manipulate text. These commands are usually one or two characters long, and can be entered with few keystrokes.
The insert mode puts anything typed on the keyboard into the current file.
Getting around VI
Open the Linux terminal.
We can start up vi by typing
vi
To edit one or more files:
vi filename1 filename2
To quit for now, press the Escape key (the editor should beep), then enter the three characters :q! and press Return:
:q!



Command will be categorized into several sections.
More around VI
Adding, Changing, and Deleting Text
Unlike normal editors we cannot replace or delete text by highlighting it with the mouse. Instead use the commands following.
Inserting or adding text to a file
Backspace - Delete the character before the cursor.
Del - Delete the character under the cursor
i - insert text before cursor, until hit
I - insert text at beginning of current line, until hit
a - append text after cursor, until hit
A- append text to end of current line, until hit
o - open and put text in a new line below current line, until hit
O- open and put text in a new line above current line, until hit
Changing text
These commands are allow modifying text
r replace single character under cursor (no needed)
R replace characters, starting with current cursor position, until hit
cw change the current word with new text, starting with the character under cursor, until hit
C change (replace) the characters in the current line, until hit
cc change (replace) the entire current line, stopping when is hit



Deleting text
These commands are allow deleting text
x delete single character under cursor
Nx delete N characters, starting with character under cursor
dw delete the single word beginning with character under cursor
dNw delete N words beginning with character under cursor; e.g., d5w deletes 5 words
D delete the remainder of the line, starting with current cursor position
dd delete entire current line
Ndd or dNd delete N lines, beginning with the current line; e.g., 5dd deletes 5 lines

Cutting and pasting text
yy copy (yank, cut) the current line into the buffer
Nyy or yNy copy (yank, cut) the next N lines, including the current line, into the buffer
p put (paste) the line(s) in the buffer into the text after the current line

To exit from VI
:x quit vi, writing out modified file to file named in original invocation
:wq quit vi, writing out modified file to file named in original invocation
:q quit (or exit) vi
:q! quit vi even though latest changes have not been saved for this vi call

0 comments:

Post a Comment

 

Copyright © 2015 {PRADEEP'S BLOG SPACE}™ is a registered trademark.

Designed by Templateism | Templatelib. Hosted on Blogger Platform.