Wednesday, September 23, 2009

VI macro for showing line numbers.

First, create a file named .exrc in your home directory or edit your current one. This is the configuration file that vi reads when it is started. Put the following two lines into this file:

    :map #1 :set number^M
    :map #2 :set nonumber^M

A very important note: create the ^M characters in this file by typing the key sequence [CTRL-V][CTRL-M]

Now, save this file and re-start vi.Now be able to display line numbers simply hit the [F1] function key, and clear line numbers by hitting the [F2] key. If you like these macros, you can create your own by following these two examples.


No comments:

Post a Comment