Sunday 21 April 2013

Some basic Linux and Unix vi commands

The vi editor is a very powerful tool to edit text, programs in Linux / Unix. VI editor is the standard text editor for all the UNIX systems and is used extensively. Commands in vi editor are input from keyboard only and no switching to mouse is required. 
  • Moving through the Text can be performed using Arrow keys. 
Basic Operation: Some Popular vi commands
  • :q exits the editor
  • :w saves the file
  • :wq save the file and then exits
  • :n moves to line n of a file
  • x will delete the character on which the cursor is positioned
  • n dw wil delete n characters to the right of the cursor
  • n dd will delete n lines from the current position of the cursor
  • :q! exits a file even if you have unsaved changes, can be referred as force exit
  • :w newfile will save the text in editor to the newfile
  • :wq! overrides read-only permission, only if you have access to change the read-only permission. Generally for root accounts. 
  • yy will copy a block of text
  • n p will paste it for n number of times
  • :recover recovers a file from any unexpected interruption
Switching the editor to insert mode. 
  • i to insert
  • a to append
  • o insert a blank line next to the cursor position and moves the cursor to that line
Learning all these commands is an easy job and any one using vi editor has to go through these all the times. If you are a Linux/UNIX newbie, these are must to get used to. 

mb.
Open source World.

2 comments:

  1. Terrific! I overwhelmed it. I have not adequate words in gratitude. Thanks for sharing with me. I will keep stay. Choosing your CMS is very influential long term I always choose Drupal. Because As the most popular non-profit websites use Durpal, I chose Drupal For my hosting I went with GetPantheon including features like Multidev which content management system do you prefer?

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...