On-Line vi Tutorials - listed in order of preference
- Purdue's Basic tutorial
- Lessons on Vi
- Vi: A UNIX Text Editor (with downloadable pdf)
- A list of vi sites
Quick Intro...
- To invoke vi, just type: vi filename. In vi, you name the file in the beginning, not at the end...
- To get out of vi depends upon what you want to do:
- To get out WITHOUT saving anything, hit ESCAPE, then shift ; (to get a colon), then q!
- To get out and SAVE what you did, hit ESCAPE and do one of the following:
- shift ; (to get a colon) then type: wq!
- type ZZ (yes, capital Z's)
- To insert text, type i, hit ESCAPE when you are done typing. You are now in "insert" mode.
- To add text right after the cursor, type a, works just like i.
- To add text beneath a line, type a lower-case o. An upper-case O will result in text being added in the line above where you are typing.
- To delete text, use x. You do not have to hit escape when you use this command. If you open a file and want to delete a few characters from the first line, hitting x will start deleting letters one at a time. You can delete multiple characters by specifying the number, i.e., 7x will delete 7 letters.
- To delete lines type dd (yes, 2 lower-case d's). You can delete multiple lines by adding a number, like 4dd. This will result in 4 lines being deleted.
- To repeat a command (like 15x, if you are editing a g98 standard orientation) simply type the command once and then hit . from then on out. This works great for the above example because you type 15x and then the down arrow in a std or file to get the spacing and tabulation correct!
Summary
| Command | Result |
| vi | invokes the vi editor |
| ESC : q! | Exits vi without saving the file |
| ESC : wq! | Exits and saves the file |
| ESC ZZ | Exits and saves the file |
| i | insert text |
| a | a text, spot next to cursor |
| x | delete characters, multiple deletions by adding number in front: 3x |
| dd | delete lines, multiple deletions by adding number in front: 3dd |
| o | add a line below the current line |
| O | add a line above the current line |
| . | repeat the previous command |
With this little tutorial, you now know enough to edit an input file for Gaussian or a com file for MacroModel. There is one last tip, which involves a combination of the above commands.
