Text Editor in Linux


  • The vi or vim editor can be used to create edit a file in Linux operating system. And it has three modes.
  • 1) cmd mode : File editing commands like copy, paste, search, replace, delete
  • 2)Insert mode: It can be used to insert text or delete text in a file.
  • 3)ex mode : Exit mode is used to save the text in a file and can be used to quit from a file.
  •        vi abc           ( can  create a file)

Press  I                     ( to insert text in a file)

Press  esc                (to come back to cmd mode)

Press  esc                (to ex mode)

Press  :w                  (to save text in a file)

Press  :q                  (to quit from a file)

Press  :wq              (to save & quit from a file)

Press  :q!                to forcefully quit without saving

Press  :wq!             To forcefully quit & save a file

Press  :u                  to undo last changes

Press  :abc             (to search abc from a file)

Press   yy               to copy a line

Press  p                   to paste

Press  dd                to delete a line

Press  5 dd            to delete 5 lines

Press  5yy             to copy 5 lines

Press  ctrl + r       to redo

Press   o                  to insert a line down

Press  shift + o     to insert a line at up

Press shift + g      to insert a cursor at end of the last line

Press shift + m    to put  cursor in middle of  screen

Press shift+h       to put cursor top of the screen

Press yw                to copy a word

Press yc                 to copy a character

Press  dw               to delete a particular word

Press 5+ dw          to delete no of words

  • cat > abc (create a file ctlr+d to save)
  • cat abc  (displays the contents of a file)
  • cp /abc  /root/abc (copy a file)
  • mv abc appin (rename a command)
  • mv appin /root (can move a file)
  • cat >> abc (append to a file)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: