The vi Editor
(vi means "visual")
(vim means "vi improved")


Part 2 of this HowTo will deal briefly with some possible difficulties you may have had in Part 1. If there were no difficulties, you may want to proceed to Part 3.

Unix commands may seem a little cryptic at times. Basic Unix Commands are a topic of another small HowTo. For now we look at just a few possible problem areas. The command ls -la which was used at the beginning of this HowTo, and shown again here in Fig. 1, is a case in point.


Fig. 1
Fig. 1

There must be a space between the command ls and the argument -la. Without the space ls-la would be interpreted as a one word command. The response would be: ls-la: command not found. If your home directory is even slightly extensive, the ls -la command will cause the files in your home directory to scroll by to the end of the list, not giving you a chance to see what they are. This is rectified with: ls -la | more. This will cause one screenfull of files to display at a time. A spacebar displays the next screenfull. A return will display the next line.

For the same reason as cited above, the command vi .exrc needs a space between vi (the command) and the filename .exrc (the argument). Additional arguments may be given as well. For example, entering vi +215 .exrc will start editing the .exrc file at line #215, which would indicate a really big .exrc file. For other files however, this can be useful.

For Windoze users, it may seem odd that it would matter that the vi command can't be entered as VI. Well, it can't. Upper and lower case are significant just about everywhere in Unix.

In the "long list" in Fig. 1, the "." all the way to the right of the first line means "current directory". In order to successfully edit and save a file in this directory, you must have "write permission". At the left end of this line is the mysterious drwxr-xr-x. The "d" means it is a directory, and then there follows three combinations of "rwx" meaning Read, Write, eXecute. The first 3 are the permissions of the "user" (dork in this case), the second 3 are permissions of the "group" (mech in this case), and the third 3 are for the rest of the world. As can be seen in the example, Dork has read, write and execute permissions for this directory (/home/dork). While read & write have fairly obvious meanings, execute, in the context of a directory may be confusing. At the top of Fig. 1, the command cd  /home/dork was entered. Without execute permission for this directory, the response to that command would have been "permission denied". That would mean that you are excluded from the /home/dork directory. Maybe you've been bad. The group mech and the rest of the world can enter this directory and read the list of files contained in it, but are not allowed to create or modify files in it.

Part 3 will deal with some commands available in vi.




(BACK) to where you were