Reputation: 47523
I'm swapping some mappings on my keyboard to make it easier on my wrist, but I wouldn't want others to be surprised if they open vim on a computer I had been working on.
So I put these mappings inside a function in my .vimrc
so I can selectively enable the mappings.
My question is, how can I tell vim (in the .vimrc
file) to call a function if I :set
a variable?
Something like :set wrist
and it would call SwapKeysForWrist
.
Note: I know I can give the function a simpler name and call it, for example :call Shahbaz()
, but that requires me to use shift three times (besides :
) which is what I'm trying to avoid. In fact, the function swaps the digits with their alternative keys (since I use those symbols much more often than actual numbers during programming), and typing parentheses (added that I'd be holding shift) does strain my wrist.
Upvotes: 0
Views: 47
Reputation: 172590
You cannot define your own :set
names, you can only use mappings or custom commands.
I would suggest using a custom :Wrist
command; it's short to type and should be easy for you to remember. If you want to get around the uppercase W
, you need to use a :cabbrev
or the cmdalias plugin.
Upvotes: 1