vi file editor in linux

Pranaam to all bhai ji _/\_
in this tutorial we will discuss about "vi" which is a text editor in linux OS.it is use to edit files.
command to open file with vi editor is :-  vi  file_name
if file does not , still editor create file temporarily :)

it is interesting editor :D it has two mode
command  mode 
insert mode

in command mode , we supply a character and that character is perform specific task like copy whole line of text, moving page up or down , counting line in a file etc etc :)
bydefault , when we open a file with vi editor , its command line mode :)

in insert mode we just type and whatever we type, it simply keep adding those words to file :)
we can enter into insert mode by pressing  keyword "i" . now we are allow to type test at any line :D
 after completion of file editing , press 'esc' key and we will be back in command line mode and now we will save that file by using command  :w
this command will save the file .

moving cursor up,down,right,left,starting or end of file:-
press j for moving cursor downward in file
press k for moving cursor up (k for kite and kite always go up ;) )
press l for moving right(l for leading :P )
press h for moving left
press $ for moving cursor to end of the current line
press zero for moving cursor at the starting of current line
press :zero(0) for moving cursor at the starting line of file
press :$ for moving cursor line at the end of file

jumping to particular line number:-
use command :line_number
here line _number is the number of line where you want to jump in file
for example i want to my cursor on line number 14 , so command will be :14

undo any change in file:-
to undo any change in file , press "u" (small u) and it will revert file to previous state.
but we need to be in command mode of vi editor (press esc key for command mode).

paste command:-
press "p" in command mode for pasting copied stuff in a file .

copy text lines(single or multiple line at a time):-
for copy of current line, press y twice (yy)  , again it should be done in command mode.
for copy of multiple lines at a time , type nyy and here n is the number of lines which you want to copy
like i want to copy 7 lines , command will be  7yy

Insert or adding text
for adding text before cursor , press i
for adding text at the beginning of current line where cursor exist, press I
for appending text next to cursor,press a
for adding text at the end of current line , press A

moving on screen
press CTRL+f   for forward down one full screen
press CTRL+b   for backword up one full screen

saving or exiting file forcefully :-
if file is not saving or quiting just by using command :w and :q respectively then add ! with command to save of quit file forcefully 
like this :w! for saving file and :q! for quiting file forcefully 
use command :wq!  for saving and quiting file forcefully

searching text in file:-
we can search for a string in file using following command
for searching string in file downward , use command    /word  and use "n'" for next occurance of keyword
for example i want to search word  indishell in file , command will be  /indishell
for searching a string in file upward, we use command ?word

copy content of file from particular line to next specified line and pasting it to another file:-
if we want to copy some lines from a file , we can use this command to copy lines from file to another
: first_line_number,last_linew file
here first line number is the line from which we want to copy data and last line is the last line upto which we want copy data, file is the file name where we want to paste data .
for example i want to copy data from line number 10 to 15 and want to save these lines in fie ica.txt
command will be like this
:10,15w  ica.txt 

Greetz to :- Guru ji Zero , code breaker ica, Aasim shaikh,Reborn, Raman kumar rana,INX_r0ot,Darkwolf indishell, Chinmay Pandya ,Silent poison India,Magnum sniper,Atul Dwivedi,ethicalnoob Indishell,Local root indishell,Irfninja indishell and Hardeep bhai <3
Share this post


:) :-) :)) =)) :( :-( :(( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ :-$ (b) (f) x-) (k) (h) (c) cheer

© 2009 Start With Linux | Mannu Linux
Designed by cyb3r.gladiat0r
Posts RSSComments RSS
Back to top