A careful study of the preceding material is sufficient for you to be well on your way to becoming proficient at vi. All you really need to do now is continue to practice what you have learned. The following material is presented for those of you who want to learn just a few more useful commands.
As you have learned, creating and opening files in vi can be a very simple matter. However, many combinations of options are available that can add much power and flexibility for these tasks, as can be seen by looking at the full syntax for opening files:
The square brackets ([ ]) around each section of arguments (modifiers) of the command indicates that they are optional. (That is, a file can be opened by just typing
As only one of many possible examples of adding options for opening files, an existing file can be opened with the cursor appearing on any desired line instead of just on the first line. (One situation in which this can be particularly useful is if your file is part of a program which you are writing and the compiler reports an error on a specific line in that file.) This is accomplished by adding the + (plus sign) command followed the desired line number. For example, to open the file "apple" with the cursor located on the third line, type:
Use of the + command without any modifying number opens a file with the cursor positioned on the last line of text. This can save some keystrokes when you want to open a file just to append data to the end of it. For example:
You have already learned several commands for switching from command mode to insert mode, including i for inserting to the left of the cursor position, a for inserting to the right of the cursor position and the c commands for changing text. A more complete list is as follows: