Thursday, 12 September 2019

ED, EX, VI EDITORS FOR LINUX

Three editors available in almost all versions of unix.
There are  :
                  1. ed editor
                  2. ex editor
                  3. vi  editor
ed editor  :-
               The ed program is basically a line editor, which means that ed assigns line numbers to lines                  in the file;  every time you do something, you must tell ed which line or lines to do it to.

ex editor :-
               An improved version of ed, called ex, understands all the commands of ed.
               Compared to ed it is shade better in  user_friendliness with more informative errors                             messages.

vi editor :-
               Compared to ed or ex the vi text editor is head and shoulders above them in almost every                     way. It is a screen editor rather than a line editor; it shows you as much of the file as it can                   fit on the screen. Vi is case-sensitive. Vi is available on almost all unix systems.

Modes of operation :-

The vi program has three modes of operation :

1). Command Mode :
              This is the default mode. In this mode all the keys pressed by the user are interpreted to be                  editor commands.

2). Insert Mode :
               This mode permits insertion of new text, editing of existing text or replacement of existing                   text.

3). The ex Command Mode :
                 This mode permits us to give commands at the command line. The bottom line of the vi screen is called the command line. Vi uses the command line to display messages and commands.
All commands entered in the ex command mode are displayed in the command line. This mode is so called because commands given in this mode are compatible with the commands of the ex editor.        
COMMAND MODE COMMANDS    

Commands for to shift command mode into insert mode.

COMMAND                         FUNCTION
         A                 -----           It places cursor at end of the current line.
         a                  -----           It places cursor right side of the current line.
         I                  -----           It places cursor at beginning of the current position.
         i                  -----           It places cursor left side of the cursor position.
         o                 -----           Enters text input mode by opening a new line immediately below                                                            the current line.
        O                 -----           Enters text input mode by opening a new line immediately above the                                                      current line.
        R                 -----           Enters text input mode and over writes from current cursor position.

To edit your text, you need to move the cursor to the point on the screen where you will begin the correction. This is easily done with four keys h, j, k and l.

        h                                    moves the cursor one character to the left.
        I                                     moves the cursor one character to the left.
        j                                     moves the cursor down on line.
        k                                    moves the cursor up on line.

POSITIONING BY CHARACTER

Command
Function
h
Moves the cursor one character to the left.
Backspace
Moves the cursor one character to the left.
L
Moves the cursor one character to the right.
Space bar
Moves the cursor one character to the right.
0
Moves the cursor to the beginning of the current line.
$
Moves the cursor to the end of the current line.


Positioning by line
Command
Function
j
Moves the cursor down one line from it’s present position, in the same coloumn.
k
Moves the cursor up one line from it’s present position, in the same direction.
+
Moves the cursor down to the begging of next line.
-
Moves the cursor upto the beginning of previous line.
Enter
Moves the cursor down to the begging of the next line..

Positioning by word
Command
Function
w
Moves the cursor to the right, to the first character of the next word.
b
Moves the cursor back to the first character of the previous word.
e
Moves the cursor down to the end of the current word.

Positioning by window
Command
Function
H
Moves the cursor to the first line on the screen, or “home”.
M
Moves the cursor back to the middle line on the screen.
L
Moves the cursor to the last line on the screen.



Commands for positioning in the File
Scrolling
Command
Function
Ctrl f
Scrolls the screen forward a full window, revealing the window of text below the current window
Ctrl b
Scrolls the screen back a full window, revealing the window of text above the current window


Commands for deleting text
Command
Function
x
Deletes the character at current cursor position.
X
Deletes the character to the left of the cursor.
dw
Deletes a word (or part of word) from the cursor to the next space or to the next punctuation.
dd
Deletes the current line
nx, ndw, ndd
Deletes  n characters, n words or n lines
d0
Deletes the current line from the cursor to the beginning of the line.
d$
Deletes the current line from the cursor to the end of the line.


Commands for copying and paste text
Command
Function
yw
Y anks word from cursor position.
yy
Y anks line from cursor position.
y$
Y anks line from cursor position of line.
y0
Y anks line from cursor position to beginning of line.
p
Paste last yanked buffer

Commands for Quitting vi

Command
Function
ZZ
Writes the buffer to the file and quits vi
:wq
Writes the buffer to the file and quits vi
:w filename
And :q
Writes the buffer to the file (new) and quits vi
:w! filename and :q
Over writes the existing file filename with the contents of the buffer and quits vi.
:q!
Quits vi whether or not changes made to the buffer were written to file. Does not incorporate changes made to the buffer and quits vi.
:q
Quits vi changes made to the buffer were written to a file.
:set nu
Setting line numbers for file
:set nonu
Removing line numbers




























No comments:

Post a Comment

Streamlining the usage of GITHUB

Streamlining the usage of Github with Commands 1. Start a new git repository under one directory locally In this step, we need to bui...