My scrapbook about anything which I learned or want to remember, Sometime about tech tips, thoughts and rambling. If you find anything useful don't forget to give thumbs-up :)

Breaking

Thursday, August 27, 2015

VI Editor in Linux - 1





Introduction to vi Editor 


  • Full-screen editor
  • Two modes of operation: command and text
  • Utilizes one letter commands
  • Does not format text
  • Flexible search and replace facility with pattern matching
  • Allows for user-defined editing functions using macros

Modes of Operation



The vi editor has two modes of operation. Command mode allows the user to perform
operations on the text, such as cut, paste, cursor movement, and replacement. These
operations are all invoked by one character “commands.” Text mode (also known as
insert mode) allows the user to enter text; all characters typed are inserted into the file.

There is no way to tell which mode the editor is in, other than pressing a key on the
keyboard. If the key you press is inserted into the file, the current mode is text mode. If
the key performs an action, the current mode is command mode.

Switching from command mode to text mode is done with one of the insert text
commands, which will be covered later. Returning to command mode is done by
pressing the <Esc> key.


Starting vi 


$ vi filename
  • If the file "filename" does not exist, it will be created
  • Otherwise, vi will open the existing file
When a session is initiated, one of two things happens:
  • If the file to be edited exists, a copy of the file is put into a buffer in temporary by default.
  • If the file does not exist, an empty buffer is opened for this session.
The tilde characters represent empty lines in the editor.  The editor starts in command mode.





No comments:

Post a Comment

Disclaimer

The postings on this site are my own and don't necessarily represent IBM's or other companies positions, strategies or opinions. All content provided on this blog is for informational purposes and knowledge sharing only.
The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. The owner will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of his information.