Featured Post

Thursday, March 24, 2016

VI EDITOR



                                             

In UNIX there are many types of editors. But the most popular editor is vi editor.We can use vi editor to create a new file or edit an existing file or just read the content of text file.

Synatx:
 
    vi filename( file name can be a text file or shell program or c program or java program etc)

    /home/anil/~$ vi hello.c
                     ----> creates and opens the new file name called hello.c if it does not exist in the system. If hello.c file is already in unix system then hello.c program will open with existing content.

~
~
~
~
~
~
"hello.c" [New File]


Operation modes in vi editor:
 
  Command mode: In this mode whatever you type is interpreted as a command. Using this mode you can perform editing text, cutting text, copying text pasting text saving quit etc. Whatever key you type it will be taken as a command

    Insert mode: This mode enables you to input text in to the file. What ever you type it will be interpreted as text and placed in the file.

vi editor always start in command mode. To enter text, you must be in insert mode. To enter insert mode press i. To get back in to command mode press esc key

Save options in vi editor:
  
  To save or quit a file in vi editor the editor must be in command mode. pressing esc key causes change from insert mode to command mode. After entering command mode we can do one of the following things

:w save the file content and return back vi editor
:q quit the editor and come to normal command prompt
:wq save the file content and quit from the vi editor

If you want to move all the way in the file with out disturbing the file content then u must be in command mode. They are many commands in vi editor. A few of them are given below.


i----->interts text before current position
I----->inserts text at beginnning of current line
a----->Inserts text after current cursor location
A---->Insert text at endof current line
k----->moves the cursor up one line
j----->moves the cursor down one line
h----->moves the cursor to left by one character position
l------>moves the cursor to the right one character position
x----->deletes the character at the cursor position
dd----> deletes the entire line


Many more commands are there but the above commands are more then enough to work in vi editor.
Make sure that if u are in insert mode what ever you enter will be added to file content. press esc key to go to command  mode and then apply commands.


                               different types of shells in UNIX



Unix operating system Linux operating system shell programming bourn shell kourne shell c shell difference between unix and linux operating system , history of UNIX, red hat operating system. UNIX OS architecture , kernel utility programs , file handling process handling inter process communication pipes shared memory message queues socket programming TCP/IP , UDP programming , One to One chat Application , Basic shell program to add two numbers , echo function , while loops clear gt lt le ge ne eq if fi while do done case array in unix strings , cut copy paste cat dir pwd getcwd chdir command read write stat lseek fstat flock mechanism.even or add program vi editor command ni vi editor command mode esc mode insert mode aa dd x :q :wq :w System calls. es,mkdir,chdir,open read pipe,shmget,shmat ,msgctl,msgsnd msgrecv, system calls. vi editor, nano editor, command mode insert mode esc mode , a, A , D, d, dd, i, I insert delete 


No comments:

Post a Comment