UNIX allows us to map functional keys like F1, F2 to some commands. .exrc file is used in order to make these mapping permanent.
For example, say everytime we open a file, when we want to see the file contents with line numbers, we go to the escape mode and type :se nu. Instead, we can have a short cut for this.
Let us see how to map the key F3 to do set line number inside vi.
SunOs/Linux:
In the Sun OS, this can be done by having the following entry in the .exrc file:
map #3 :se nu
HP-UX:
In the HP machine, it is a bit different because the key codes are read differently. Have the following entry in your .exrc file:
map ^[[13~ :se nu
Note: The above map pattern is actually typed as shown below:
^[[11~ = Ctrl-V + Esc + [ + 1 + 3 + ~
Once this setting is done, open a file in vi, and press F3 and enter, you should see the line numbering done.
No comments:
Post a Comment