Vi Map Keys

Problem

Are there a combinations of key strokes you constantly enter?



Solution

Maybe you are a Java programming! 🙂 Or PHP/Perl – either way if you are using vi a lot, these tips could be worth your pc’s weight in gold. 😉



Example


To create a one time map (of any key), just run this within vi:


:map #1 :!echo hey mapped f1^M

You need to hold down control and hit m to get the return, so this will run itself (no enter required).

To see current maps, just type :map

To make it permanent, just add same syntax to $HOME/.exrc

I think another good tip, is to map f1 to cat the exrc – like this:


:map #1 :!cat $HOME/.exrc^M

Then map #2, 3, 4 …





Leave a Reply

Your email address will not be published. Required fields are marked *