LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Vim map - to _ and the reverse (https://www.linuxquestions.org/questions/linux-software-2/vim-map-to-_-and-the-reverse-477869/)

sadarax 08-27-2006 04:19 PM

Vim map - to _ and the reverse
 
I am trying to get vim to switch the - and the _ keys. I have got vim to map the - to the _, which is really handy when I am programming. I used

Code:

imap - _
Now, I cannot get it to the reverse, meaning I want to to print a '-' when I would use the key sequence for an '_' (Shift + -). Whatever I map gives me a recursive mapping (which makes sense I guess). Does anyone know how to make this work?

Valdis Grinbergs 08-27-2006 10:52 PM

The following will do it:

As you have already done:
imap - _
imap _ -

Type the following two commands as well:

inoremap - _
inoremap _ -


All times are GMT -5. The time now is 10:45 AM.