Working with vi

The editor found on nearly every UNIX and Linux system is, without a doubt, the vi editor, originally written by Bill Joy. This simple to use but incredibly capable editor features a somewhat cryptic command set, but you can put it to use with only a few commands. Although older, more experienced UNIX and Linux users continue to use vi extensively during computing sessions, many newer users might prefer learning an easier to use text editor such as pico or GNU nano. Die-hard GNU fans and programmers definitely use emacs.

That said, learning how to use vi is a good idea. You might need to edit files on a Linux system with a minimal install, or a remote server without a more extensive offering of installed text editors. Chances are better than good that vi will be available.

You can start an editing session by using the vi command like this:

The vi command works by using an insert, or editing mode, and a viewing (or command) mode.

When you first start editing, you will be in the viewing mode. You can use your cursor or other navigation keys (as shown later) to scroll through the text. To start editing, press the i key to insert text or the a key to append text. When finished, use the Esc key to toggle out of the insert or append modes and into the viewing (or command) mode. To enter a command, type a colon (:), followed by the command, such as w to write the file, and press Enter.

Although vi supports many complex editing operations and numerous commands, you can accomplish work by using a few basic commands. These basic vi commands are

• Cursor movement h, j, k, l (left, down, up, and right)

• Delete character x

Was this article helpful?

0 0

Post a comment