In this section we will discusses the main text editors you'll see in the Linux world. Now we are going to discuss our first editor.
Vi (visual editor) or VIM (VI iMproved)
This is the classic screen-based editor for UNIX. The vi editor works in two modes,
To start vi
, simply type
# vi <filename>
(you can set absolute path also)
If you want to make a file in /etc/mohit
directory then you can give command like this
# vi /etc/mohit/<file name>
If do not specify path then file would be save in current working directory
Linux vi editor
In above figure op
is file name press enter, next screen would be.
Linux vi editor
At this moment vi
editor is in command mode if want to write anything press I
Now you can type your text.
Linux vi editor in Insert mode
After typing if you want to save this, need to enter in command mode.
key to enter in command mode.
After this you can specify you aim.
for save the text
for quit after save
quit after save the text
quit without save
Save file in Linux vi editor
Navigation is rudimentary thing for test editor. Use following commands for navigation
left one space
right one space
down one space
up one space
moves the cursor forward one word.
moves the cursor backward one word.
moves the cursor to the top line of the screen.
moves the cursor to the middle line of the screen.
moves the cursor to the last line of the screen.
Searching Text in vi editor
In order to search the string in file use the following commands.
search forward for occurrence of string in text
search backward for occurrence of string in text
move to next occurrence of search string
move to next occurrence of search string in opposite direction
Searching string in Linux vi editor
Copying Text with Yank
In order to make duplicate copy of existing line. You can use yank.
copies a word into a buffer (7yw copies 7 words)
copies a line into a buffer (3yy will copy 3 lines)
In order to delete text in vi editor use following commands :
delete one character
delete the current word (Note: ndw deletes n numbered words)
delete the current line (Note: ndd deletes n numbered lines)
For more command you can see the man page of vi.