September 11th, 2005, 02:15 AM
(new versions of linux will open up VIM when you enter VI..which is what we'll be dealing with here)
A win32 version is available Here.
linux help and man files are very informative...but not very helpful if you're new to linux. when i read the vim man file for the first time i could swear i saw things like..."to capitolize the second letter of the forth word in every third line spin your chair around three time then punch the keyboard". so for the longest time i would just install joe or pico
below is all you really need to know to use VI/VIM to view/edit ascii files. of course once you've learned to use it there are many more commands and options that will help you use it well. VIM It is a very powerful tool but being as this is for 'basic survival' we will not be dealling with the advanced stuff.
if you want to view the contents of a file using vim simply type 'vi filenane' at the prompt. filename being the name of the file you wish to open. If the file is in a directory other than the one you are in the path must be included with the file name. You are now in 'VIEW' mode and no changes can be made.
if you wish to edit this file you'll need to enter 'insert mode' by hitting the 'insert' key on the keyboard. you wll see --INSERT-- appear at the bottom left on your screen. you can now make all the changes you need. use the cursor (arrow) keys on the keyboard to navigate to where you want to make the changes in the document and simply type, delete, whatever.
when you've finished viewing and/or editing you need to return to view mode...this is done by pressing the 'Esc' key. you'll notice --INSERT-- will be gone.
so if you find yourself typing in a file you didn't want to be typing in simply enter :qa! and no harm will have been done
if no changes have been made :q and press enter
to save changes :wq and press enter
quit and not save :qa! and press enter
NOTE: the ':' must be typed along with the letter/s of the command
The easiest way to creat a new file is simply add the name you want to give the new file as an argument to vi (vi newfilename), enter insert mode, put what you want into the file, switch to view mode (Esc) then save the changes (:wq). a simple ls will show newfile listed there and a 'cat' will show the text you added are in that file.
you can also create a new file by just opening vim, entering insert mode, put in what you want, return to view mode (Esc) then put the name you want to give this file after the write/quit command (:wq newfile).
there is one more feature id like to cover. although its a little beyond survival it can make life allot easier.
if your need to change one string a long .conf or script... while in view mode type the string preceeded by a foward slash (/somestring). as you are typing you'll notice the letters typed are being highlighted at the first location that contains them all. when you get to the full string where you want to make the change, hit enter to be in insert mode at the spot. make your changes then write and quit.
To get help while in insert mode hit <F1>, while in view mode use either F1 or enter :h
ok! let's do a quick exercise.
at the prompt enter 'vi test' (without the quotes). Now hit Insert and type 'this is not a test'. get out of insert mode by pressing 'Esc' the save and quit by entering ':wq' (no quotes...anywhere)
you should be back at the prompt.
now again type vi test. you'll find the text you typed earlier has indeed been saved in the file called test that you created.
now type '/not' hit enter then hit insert. hit del three times then type 'just'. press 'Esc' to leave insert mode, save the changes and exit
a quick 'cat test' should show you your changed sentence.
congrats! your now a vi user. well not a very advanced one but a user just the sam and we got to start somewhere.
Bukhari:V3B48N826 “The Prophet said, ‘Isn’t the witness of a woman equal to half of that of a man?’ The women said, ‘Yes.’ He said, ‘This is because of the deficiency of a woman’s mind.’”