Site Administration Page 8 - Vi 101 |
You've already seen that starts vi with the file specified already loaded. But why restrict yourself to one - you can load multiple files in this manner: To switch between files, use these commands: :next = go to the next file in the file list :rewind = go to the first file in the file list :last = go to the last file in the file list To exit all files at once, use to exit without saving, or to save all changes and exit [the "a" here means "all"] Once you've started vi, you can also load a new file into the editor with the "edit" command, like this If you'd prefer to insert the contents of another file directly into the document you're currently editing, there's a "read" command designed to do just that. Try it! If you're a programmer, you'll definitely appreciate vi's ability to provide you with multiple views of the same file, referred to in geek speak as "window splitting". And the command is, naturally, Each of the windows created can be manipulated independent of the others, although changes made to the file will be immediately visible in all of them. Let's take it one step further - how about having *different* files loaded into each of the windows? For example, wouldn't it be nice if you could load an HTML form into one, the associated CGI script into another, some help documentation into the third, and have all three visible at the same time? Well, you can - simply use the "new" command to create a new window for each file, like this: To switch between windows, use
This article copyright Melonfire 2000. All rights reserved.
blog comments powered by Disqus |