Vi: Difference between revisions
No edit summary |
No edit summary |
||
Line 3: | Line 3: | ||
vi httpd.conf | 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 | this opens the file in command mode, assuming you're in the directory that contains httpd.conf. The other mode is insert mode, where we want to insert text. so we type | ||
i | i |
Revision as of 20:05, 30 October 2005
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, assuming you're in the directory that contains httpd.conf. 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. Remember to hit "i" to get back into Insert mode to edit again.
Once you're happy with your changes, hit ESCape to get back to command mode and then:
: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. The ! forces the changes to be made.