Vi editor
The Vi editor is the text editor mostly available in all Unix and Linux flavors. This editor is used to create the files and modifies the files.
In this VI indicates that visual interface.
In the new versions of Linux, vim editor is coming which is Vi improved version.
There are three modes in vi editor
- Command mode
- Insertion mode
- Execution mode
By opening the file using vi editor first it will go to command mode.
Command mode
In command, we can modify the file like copy, paste and delete the lines etc.,
Press ctrl+R to redo the operation
/<search_word> is used to search a particular word in the document or file.
The subcommands used to do particular operations in the file are as follows.
Command | Operation |
---|---|
Esc+cw | To change the word |
Esc+dw | To delete the word |
Esc+r | To replace the character |
Esc+shift+r | To replace the line |
Esc +a | To move courser to at the end of the word |
Esc+shift+a | To move courser to the end of the line |
Esc+o | To add the line below the courser |
Esc+shift+o | To add the line above the courser |
Esc+shift+gg | To move courser last page to the last line |
Esc +dd | To delete the line |
Esc+ndd | To delete the number of lines |
Esc+shift+o | To add the line above the courser |
Esc+ yy | To copy the line |
Esc+p | To paste the copied lines |
Esc+nyy | To copy the number of lines |
Esc+u | To undo the operation |
Esc+ctrl+R | To redo the operation |
Insertion mode
By pressing a,I we will go to insertion mode from command mode. To go back to the command mode press Esc button.
You can navigate through the text using the dos keys.
Execution mode
By pressing shift+: we will go to to the execution mode. in the execution mode, we will do the tasks like saving the file, quitting from the file etc.,
The following are the commands in the execution mode to do the particular tasks.
Command | Operation |
---|---|
Shift+ | Goes from command mode to the execution mode |
Shift+set nu | To set line numbers to the file |
Shift+set nu | To set line numbers to the file |
Shift+:set nonu | To unset the line numbers |
Shift+set nu | To set line numbers to the file |
Shift+:wq! | To save and quit forcefully |
Shift+q! | To quit without saving forcefully |
Shift+:1,$s/old_string/new_string /g | To replace the string |
0 comments:
Post a Comment