Monday, August 23, 2010

Working with 'vi' editor

People who use Linux/Unix as their OS should have used the vi editor. This editor is more powerful editor I've seen ever. I'm here with listing some basic & important 'vi' commands which needed to do file manipulation/editing.

Save & Exit:

:x --> quit vi, writing out modified file to file named in original invocation
:x --> quit vi, writing out modified file to file named in original invocation
:wq --> quit vi, writing out modified file to file named in original invocation
:q --> quit (or exit) vi
:q! --> quit vi even though latest changes have not been saved for this vi call

Screen manipulation:

^f -->move forward one screen
^b -->move backward one screen
^d -->move down (forward) one half screen
^u -->move up (back) one half screen

Working with Multiple files:

To open multiple files:

$vi main.pl maintenance.pl

To hop between them:

:n --> Next file
:prev --> Previous file
:args --> To see which are the files open.

No comments:

Post a Comment