2010-09-10 10 views
0

J'écris beaucoup de code et je suis fatigué d'appuyer sur shift chaque fois que j'ai besoin d'un caractère spécial. Et puisque j'utilise souvent des caractères spéciaux, puis des nombres, je veux inverser le comportement de décalage sur eux.Caractères spéciaux VIM sans touche shift

Donc, si je tape < 4> Je vais obtenir « $ » et si je tape <changement> + 4 <> Je vais prendre « 4 » et ainsi de suite pour chaque numéro. Ce mappage ne devrait fonctionner qu'en mode insertion.

J'ai essayé:

:set langmap 123...;[email protected]#...,[email protected]#...;123 "works only in normal-mode 

:imap 4 $ 
:imap $ 4 "recursive mapping error 

Répondre

4

Utilisez :ino, qui fait la même chose que :imap sauf qu'il ne semble pas pour les cartes dans le texte remplacé. (C'est un raccourci pour 'inoremap') Cela va résoudre le problème de récursivité.

Voir ici pour plus d'informations: http://vim.dindinx.net/orig/html/map.txt.php

Ou Type: carte h pour l'aide en ligne de vim (même chose, juste à l'intérieur vim).

0

De :help imap:

If you want to exchange the meaning of two keys you should use the :noremap 
command. For example: > 
    :noremap k j 
    :noremap j k 
This will exchange the cursor up and down commands. 

With the normal :map command, when the 'remap' option is on, mapping takes 
place until the text is found not to be a part of a {lhs}. For example, if 
you use: > 
    :map x y 
    :map y x 
Vim will replace x with y, and then y with x, etc. When this has happened 
'maxmapdepth' times (default 1000), Vim will give the error message 
"recursive mapping". 

va de même pour imap (utilisation inoremap à la place).