Vi

From Hackepedia
Revision as of 21:02, 30 October 2005 by Frankk (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

For some reason you have to edit a file on unix, and have never done so before, and the only editor around is "vi". We'll use httpd.conf and the example file to edit:

vi httpd.conf

this opens the file in command mode. The other mode is insert mode, where we want to insert text. so we type

i

and now we're in insert mode. We can move throughout the text and edit as we please. If we make a typo we hit the ESCape key to go back to command mode and type

:u

which means undo last edit. If you've made a few mistakes and want to start over

:e 

will do this. Once you're happy with your changes,

:wq! 

will force the changes to be saved to disk. I would recommend trying it without the ! and just do

:wq

but watch for errors like file permission issues.