Linux Utilities | Part 3

Linux Utilities | Part 3
The visual editor "vi" is a full-screen editor; it always maintains an image on your screen of a portion of the file you are editing. It requires a terminal that enables it to control the position of the cursor and place text at an arbitrary position on the screen
As you edit, the screen displays a portion of the buffer the visual cursor vi's position in the buffer.
The current line is the line containing the cursor.
The bottom of your screen is the status line which vi uses for the following purposes:
  • Error messages appear on the status line
  • When vi generated status information such as the name of the current file in response to to a command, this infiormation appears on the status line
  • As you type search pattern or an ex command, vi echoes whhat you are typing to the status line
  • The interrupt- key, which interrupts and cancels whatever you are doing
  • The kill key which ersaes all the chracters you have typed on the curent line
  • The erase key which erases the chracter to the left of the cursor(if you did not type the character as part ofthe current input operation, however, erase won't erase it)
  • Command mode is teh mode for issuing short commands .In command mode,vi treats each charcter you type a s a command to do something or as part of such a command;the charcter is not echoed to your terminal
  • Input mode is the mode for inserting text into the buffer. In input kode,vi treats each character you type as data and echoees ot to the terminal, adding it at the cursor positioon and moviingg the vcursor pone position to the right
  • Status-line mode is the mode for issuing long comjmmands. As you type characters, instead status-line mode, vi echoes them to the status line. When you finish the command vi executes it

Some commands take objects. An object is pecidfoied by a command that moves a cursor;the object denotes the region of text pqaassed over by the command Commands that accept input text such as 'i','A','o' initiate input mode

The ';' command, which introduces as an ex command initiates status line mode.
The searching commands '/' and '?' also initiate status-line mode

vi commands:-

  • j => Moves directly down one line
  • k => Moves directly up one line
  • o => Moves to the first chracter on the current line
  • $ => Moves to the last character on the current line
  • nl => Moves to column n of the current line

vi does not have any explicit commands for moving and copying text

Instead, you move etxt in two steps:
  • Deleteing it from its original location
  • Putting it in its new location

Example:

To move the next 2 lines to another place, type '2dd', move to the place you want to put the line and type,

vi has a aset of 26 named buffers for holding text, named by the letters of the alphabet.
Commands
  • u => Undoes the most recent change, insertion or macro-defined command
  • U => Restores the current line to teh state it was in when you most recently started editing it by pressing the 'i' key
  • :wq or ZZ => Saves the buffer you are editing and exists from vi
  • :q!, Quits vi, abandioning the buffer

vi command line options:

  • -t tag
  • Edit the file containing tag. The cursor is initially positioned at the tag
  • -r
  • Attempt to recover the specified files after and editor or system crash
  • -R
  • Edit these files in read-only mode
  • -c cmd
  • Execute "cmd" before starting to edit file oin the file list
  • -w size
  • Set the default size of a screenful as recorded on the window variable, to "size"
  • If you are stuck and neeed to get out of vi quickly, there are two sure ways to do it
  • If you want to save the file you are working on, type Escape key + ZZ
  • If you don't carw about saving the file type:q! Enter

Adjusting the screenful

  • Ctrl + F => Scrolls down (forward) one screen
  • Ctrl + B => Scrolls up (backward) one screen
  • Ctrl + D => Scrolls down by half a screen
  • Ctrl + U => Scrolls up by halgf a screen
  • Ctrl + E => Scrolls down by one line
  • Ctrl + Y => Scrolls up by one line

The following command moves the cursor horizontally or vertically

  • space + l => movrs right one character

Example screenshots:

Comments

Popular posts from this blog

Laravel | PHP | Basics | Part 2

Apache Hadoop | Running MapReduce Jobs

Parallel Database design, query processing