Friday, March 6, 2020

Vi Editor

VI EDITOR :-
--------------
VI editor is case sensitive, used in two modes Command mode and Insert mode. By default it starts in command mode, to enter text you must enter into the insert mode. Press letter 'i' to enter into the insert mode. Press 'esc' key to come out of the insert mode, back to the command mode.


COMMANDS :-
---------------

vi Filename : Opens existing file and creates new file, if no file exists.

vi -R Filename : Opens existing file in the read only mode.

vi Filename : Opens existing file in the read only mode.

:w : This command is used to save content of the file.

:q : This command is used to come out of vi editor.

:wq :  This command is used to save and quit from the content of the file.

:q! : This command is used to come out of vi editor, if the file is modified without saving it.  

ctrl + zz : This command is used to save and quit from the content of the file.

:w filename : This command is used to save the specific file.


MOVE WITHIN THE FILE :-
-----------------------------

To move the within the file, you must be in command mode. So press Esc key twice followed by the below words.

k : Moves the cursor one line up.

j : Moves the cursor one line down.

h : Moves the cursor to the left one character position.

i : Moves the cursor to the right one character position.


EDITING THE FILES :-
------------------------

To edit file you need to be in insert mode. Many ways to enter the data into the files are mentioned below.

i : Used to enter into the insert mode and type data as per our requirement.

l : Used to enter text at the begining of the current line.

A : Used to enter text at the end of the current line.

o : Used to create new line below the cursor location.

O : Used to create new line above the cursor location.


DELETING THE CHARACTERS :-
----------------------------------

x : Used to delete the characters under the cursor location.

X : Used to delete the characters before the cursor location.

dw : Used to delete current cursor location to the next word.

d^ : Used to delete current cursor location to the begining of the line.

d$ : Used to delete current cursor location to the end of the line.

D : Used to delete current cursor position to the end of the current line.

dd : Used to delete the line the cursor is on.

No comments:

Post a Comment

Date Functions in SQL

Select Getdate() as CurrentDate; Select Getdate() -1 PreviousDate; Select Getdate() +1 NextDate; Select DATEADD(dd,1,getdate()) as NextDate;...