Mercurial > vim
comparison runtime/doc/map.txt @ 588:d133e7c550d0
updated for version 7.0167
author | vimboss |
---|---|
date | Sun, 11 Dec 2005 21:27:22 +0000 |
parents | 862863033fdd |
children | 6a91f35b354d |
comparison
equal
deleted
inserted
replaced
587:3686831cf3da | 588:d133e7c550d0 |
---|---|
1 *map.txt* For Vim version 7.0aa. Last change: 2005 Oct 14 | 1 *map.txt* For Vim version 7.0aa. Last change: 2005 Dec 11 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
423 for the {lhs}. You will have to avoid keys that are used for Vim commands, | 423 for the {lhs}. You will have to avoid keys that are used for Vim commands, |
424 otherwise you would not be able to use those commands anymore. Here are a few | 424 otherwise you would not be able to use those commands anymore. Here are a few |
425 suggestions: | 425 suggestions: |
426 - Function keys <F2>, <F3>, etc.. Also the shifted function keys <S-F1>, | 426 - Function keys <F2>, <F3>, etc.. Also the shifted function keys <S-F1>, |
427 <S-F2>, etc. Note that <F1> is already used for the help command. | 427 <S-F2>, etc. Note that <F1> is already used for the help command. |
428 - Meta-keys (with the ALT key pressed). | 428 - Meta-keys (with the ALT key pressed). |:map-alt-keys| |
429 - Use the '_' or ',' character and then any other character. The "_" and "," | 429 - Use the '_' or ',' character and then any other character. The "_" and "," |
430 commands do exist in Vim (see |_| and |,|), but you probably never use them. | 430 commands do exist in Vim (see |_| and |,|), but you probably never use them. |
431 - Use a key that is a synonym for another command. For example: CTRL-P and | 431 - Use a key that is a synonym for another command. For example: CTRL-P and |
432 CTRL-N. Use an extra character to allow more mappings. | 432 CTRL-N. Use an extra character to allow more mappings. |
433 | 433 |
456 option). After that it assumes that the 'q' is to be interpreted as such. If | 456 option). After that it assumes that the 'q' is to be interpreted as such. If |
457 you type slowly, or your system is slow, reset the 'timeout' option. Then you | 457 you type slowly, or your system is slow, reset the 'timeout' option. Then you |
458 might want to set the 'ttimeout' option. | 458 might want to set the 'ttimeout' option. |
459 | 459 |
460 *map-keys-fails* | 460 *map-keys-fails* |
461 There is one situation where key codes might not be recognized: | 461 There are situations where key codes might not be recognized: |
462 - Vim can only read part of the key code. Mostly this is only the first | 462 - Vim can only read part of the key code. Mostly this is only the first |
463 character. This happens on some Unix versions in an xterm. | 463 character. This happens on some Unix versions in an xterm. |
464 - The key code is after character(s) that are mapped. E.g., "<F1><F1>" or | 464 - The key code is after character(s) that are mapped. E.g., "<F1><F1>" or |
465 "g<F1>". | 465 "g<F1>". |
466 | |
466 The result is that the key code is not recognized in this situation, and the | 467 The result is that the key code is not recognized in this situation, and the |
467 mapping fails. | 468 mapping fails. There are two actions needed to avoid this problem: |
468 There are two actions needed to avoid this problem: | 469 |
469 - Remove the 'K' flag from 'cpoptions'. This will make Vim wait for the rest | 470 - Remove the 'K' flag from 'cpoptions'. This will make Vim wait for the rest |
470 of the characters of the function key. | 471 of the characters of the function key. |
471 - When using <F1> to <F4> the actual key code generated may correspond to | 472 - When using <F1> to <F4> the actual key code generated may correspond to |
472 <xF1> to <xF4>. There are mappings from <xF1> to <F1>, <xF2> to <F2>, etc., | 473 <xF1> to <xF4>. There are mappings from <xF1> to <F1>, <xF2> to <F2>, etc., |
473 but these are not recognized after another half a mapping. Make sure the | 474 but these are not recognized after another half a mapping. Make sure the |
478 Another solution is to use the actual key code in the mapping for the second | 479 Another solution is to use the actual key code in the mapping for the second |
479 special key: > | 480 special key: > |
480 :map <F1><Esc>OP :echo "yes"<CR> | 481 :map <F1><Esc>OP :echo "yes"<CR> |
481 Don't type a real <Esc>, Vim will recognize the key code and replace it with | 482 Don't type a real <Esc>, Vim will recognize the key code and replace it with |
482 <F1> anyway. | 483 <F1> anyway. |
484 | |
485 Another problem may be that when keeping ALT or Meta pressed the terminal | |
486 prepends ESC instead of setting the 8th bit. See |:map-alt-keys|. | |
483 | 487 |
484 *recursive_mapping* | 488 *recursive_mapping* |
485 If you include the {lhs} in the {rhs} you have a recursive mapping. When | 489 If you include the {lhs} in the {rhs} you have a recursive mapping. When |
486 {lhs} is typed, it will be replaced with {rhs}. When the {lhs} which is | 490 {lhs} is typed, it will be replaced with {rhs}. When the {lhs} which is |
487 included in {rhs} is encountered it will be replaced with {rhs}, and so on. | 491 included in {rhs} is encountered it will be replaced with {rhs}, and so on. |
552 for a mapping is done again (so you can map an internal code to something | 556 for a mapping is done again (so you can map an internal code to something |
553 else). What is written into the script file depends on what is recognized. | 557 else). What is written into the script file depends on what is recognized. |
554 If the terminal key code was recognized as a mapping the key code itself is | 558 If the terminal key code was recognized as a mapping the key code itself is |
555 written to the script file. If it was recognized as a terminal code the | 559 written to the script file. If it was recognized as a terminal code the |
556 internal code is written to the script file. | 560 internal code is written to the script file. |
561 | |
562 | |
563 Mapping ALT-keys *:map-alt-keys* | |
564 | |
565 In the GUI Vim handles the Alt key itself, thus mapping keys with ALT should | |
566 always work. But in a terminal Vim gets a sequence of bytes and has to figure | |
567 out whether ALT was pressed or not. | |
568 | |
569 By default Vim assumes that pressing the ALT key sets the 8th bit of a typed | |
570 character. Most decent terminals work that way, such as xterm, aterm and | |
571 rxvt. If your <A-k> mappings don't work it might be that the terminal is | |
572 prefixing the character with an ESC character. But you can just as well type | |
573 ESC before a character, thus Vim doesn't know what happened (except for | |
574 checking the delay between characters, which is not reliable). | |
575 | |
576 As of this writing, some mainstream terminals like gnome-terminal and konsole | |
577 use the ESC prefix. There doesn't appear a way to have them use the 8th bit | |
578 instead. Xterm, aterm and rxvt should work well by default, unless you tweak | |
579 resources like "metaSendsEscape", "eightBitInput" and "eightBitOutput". | |
580 | |
581 On the Linux console, this behavior can be toggled with the "setmetamode" | |
582 command. Bear in mind that not using an ESC prefix could get you in trouble | |
583 with other programs. You should make sure that bash has the "convert-meta" | |
584 option set to "on" in order for your Meta keybindings to still work on it | |
585 (it's the default readline behavior, unless changed by specific system | |
586 configuration). For that, you can add the line: > | |
587 | |
588 set convert-meta on | |
589 | |
590 to your ~/.inputrc file. If you're creating the file, you might want to use: > | |
591 | |
592 $include /etc/inputrc | |
593 | |
594 as the first line, if that file exists on your system, to keep global options. | |
595 This may cause a problem for entering special characters, such as the umlaut. | |
596 Then you should use CTRL-V before that character. | |
597 | |
598 Bear in mind that convert-meta has been reported to have troubles when used in | |
599 UTF-8 locales. On terminals like xterm, the "metaSendsEscape" resource can be | |
600 toggled on the fly through the "Main Options" menu, by pressing Ctrl-LeftClick | |
601 on the terminal; that's a good last resource in case you want to send ESC when | |
602 using other applications but not when inside VIM. | |
557 | 603 |
558 ============================================================================== | 604 ============================================================================== |
559 2. Abbreviations *abbreviations* *Abbreviations* | 605 2. Abbreviations *abbreviations* *Abbreviations* |
560 | 606 |
561 Abbreviations are used in Insert mode, Replace mode and Command-line mode. | 607 Abbreviations are used in Insert mode, Replace mode and Command-line mode. |