Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Apple > Operating Systems

  • Print
  • + Share This
This chapter is from the book

Configuring vi

In addition to reading configurations from your shell, the vi editor will also read config-urations from a text file, and since we've already shown you how to use it (in Chapter 6, "Editing and Printing Files"), We'll show you some common configuration settings you may want to use.

To configure vi:

  1. Open your ~/.exrc file (using vi, of course!).

  2. Add the setting(s) you wish to use. For example, to display the current mode (command or insert) on the status line (very useful for beginners!):

    set showmode
  3. To have word wrap (indicated by wm) always be on, and to set it to kick in within five characters of the right edge of the screen, add a line that says

    set wm=5
  4. To set a tab stop every four spaces (instead of the default eight), add a line that says

    set tabstop=4

    Table 7.6 lists some common setting possibilities, and of course you should read the vi man page to see the full list.

    Table 7.6 Common vi Configuration Settings



    set autoindent

    Vi will insert tabs and spaces at the start of each line to make the first character you type line up with the first character of the line above.

    set extended

    Allows extended regular expressions to be used in searches. See Chapter 4, "Useful Unix Utilities," the section "Searching for Text," for a discussion of regular expressions.

    set ruler

    Causes vi to display the position of the cursor at the bottom of the window (as two numbers: line,column).

    set showmode

    Displays the current mode (command or insert) on the status line.

    set tabstop=n

    Tells vi how many spaces between each tab stop. If you set it to 4, then pressing twill advance the cursor only four spaces.

    set wm=n

    Turns on automatic word wrap. Vi will automatically insert a new-line character when you get within n columns of the right edge of the screen.

  5. Save the file.

  6. Quit.

The new settings will be in effect the next time you use vi.

  • + Share This
  • 🔖 Save To Your Account