Thursday, July 31, 2008

Mapping of key for vi editor

Any key can be mapped for vi editor to perform any of the editor commands. For this the map command is to be used.

for mapping “ctrl+s” to save file and quit which is nothing but “wq” in terms of editor commands. On command line of vi editor in escape mode write,

:map ctrl+s :wq^M

Here you will actually press ctrl+s, and to produve ctrl M character use ctrl+v and then perss m.

The ^M character is required to act as enter key, without this the “wq” will appear at the command line of vi editor.

Now as you have run this command in a particular vi session, next time you open vi you will again have to map it. Instead you can write the command in .exrc file in your home directory.

No comments:


My Blog List