Loading...
Basic Linux

Types Of Editors

Editors:

Editors are used for adding, modifying and / or deleting  text.
The types of different editors used are:

  1. Windows:
    notepad
  2. DOS:
    edit
  3. Linux/Unix
    CLI based  : ex , ed , vi or vim, etc.
    GUI based  : Emacs, Gedit, nedit, nano, and pico, etc.

Editors:

  • VI editor is a screen-oriented text editor written by Bill Joy in 1976.
  • This is the most commonly used editor for editing files in Linux.

VI Editor Mode:
VI editor has three modes of operations.

  • Command Mode
  • Insert Mode
  • Ex Mode (Extended Command Mode)

To go Insert Mode from Command Mode

iInserts the text at the current cursor position
lInserts the text in beginning of a line
aAdds the text after the current cursor position
AAdds the text at the end of a line
oInserts the text one line below current cursor position
OInserts the text one line above current cursor position

Ex mode:

:qQuit without saving
:q!Quit forcefully without saving
:wWrite (save)
:wqSave and quit
:wq! (or) : xSave and quit forcefully
:se nu (or) :set nuSets line numbers
:se nonu (or) :set nonuRemoves line numbers
:nJumps to line n
:! (UNIX command) Eg: :! pwdTo execute UNIX commands
: XTo give password to the file and remove password
:/string/To search a word in the file
:84The cursor goes to line 84
%s/old name/new nameReplace the particular keyword in first line
%s/old name/new name/gReplace all matching keywords in all the lines
%s/old name/new name/giTo ignore case sensitive
%s/old name/new name/gcAsk for confirmation

Command Mode:

emoves to the end of the word
bMoves to beginning of the word
$Moves to the end of the line
^Moves to the beginning of the line
HMoves to the first line onscreen
Mmoves to the middle of the onscreen
LMoves to the last line onscreen
dd Deletes a line
nddDeletes ‘n’ lines
yyCopies a line
nyyCopies ‘n’ lines
pPaste below the cursor line
PPaste above the cursor line
uUndo (you can undo 1000 times)
Ctrl+rRedo
gggo to beginning of the file
GMoves the cursor to the last line of the file  
/<word to find>Finds a word (press n for next)
nFind next occurrence of search word
NFind previous occurrence of search word
.Repeat last command action

VI Editor:
To create file

[root@webnoidschools ~]# vi  <filename> 

To create  multiple file

[root@webnoidschools ~]# vi m –o <filename1>  <filename2> 

Leave a Reply

Your email address will not be published. Required fields are marked *