The VI Editor


© Robin Friedman
Articles in this Topic    Discussions in this Topic

VI is unquestionably one of the most popular text editors ever to exist in Unix, and also one of the most inscrutable. It may seem like it could not have been created by rational human beings at first. You must, however, keep in mind that VI was engineered to provide as much functionality as possible, while still being small in size and compatible with all Unix systems. So while it may not be intuitive, it will do you good to learn an editor that's standard on just about every Unix system.

Start by typing vi filename to edit that filename, or create it if it doesn't exist.

To move the cursor around the document, you can use the arrow keys, or h, j, k, and l, for left, up, down, and right, respectively.

To begin typing text, press a to append after the cursor, or i to insert before the cursor. When done typing, press the Esc key to go back to command mode, in which you can preform all the commands you want. One useful command is :set showmode, which will display the current mode in the lower right-hand corner.

To delete a character, hit x for after the cursor, or X for before the cursor. To delete a whole word, press dw. To delete a line, use dd. To replace a character, use r.

To search your document, type ?whatyouaresearchingfor to search backwards, or /whatyouaresearchingfor to search forwards.

When you're done editing the file, you can type ZZ to save the file and then quit. :w will save your file without quitting, and :q! will quit without saving any changes.

These are just a few of the VI commands that I often use. To unleash more of its surprising power, check out a VI command reference like http://www.cs.wustl.edu/~jxh/vi.html or http://www.eng.hawaii.edu/Tutor/vi.html

Go To Page: 1


Post this Article to facebook Add this Article to del.icio.us! Digg this Article furl this Article Add this Article to Reddit Add this Article to Technorati Add this Article to Newsvine Add this Article to Windows Live Add this Article to Yahoo Add this Article to StumbleUpon Add this Article to BlinkLists Add this Article to Spurl Add this Article to Google Add this Article to Ask Add this Article to Squidoo