Skip to content

Commit 4b57018

Browse files
committed
patch 8.1.2194: modifyOtherKeys is not enabled by default
Problem: ModifyOtherKeys is not enabled by default. Solution: Add t_TI and t_TE to the builtin xterm termcap.
1 parent a139615 commit 4b57018

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

runtime/doc/map.txt

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ manual.
2020
1.8 Examples |map-examples|
2121
1.9 Using mappings |map-typing|
2222
1.10 Mapping alt-keys |:map-alt-keys|
23-
1.11 Mapping an operator |:map-operator|
23+
1.11 Mapping in modifyOtherKeys mode |modifyOtherKeys|
24+
1.12 Mapping an operator |:map-operator|
2425
2. Abbreviations |abbreviations|
2526
3. Local mappings and functions |script-local|
2627
4. User-defined commands |user-commands|
@@ -777,6 +778,9 @@ In the GUI Vim handles the Alt key itself, thus mapping keys with ALT should
777778
always work. But in a terminal Vim gets a sequence of bytes and has to figure
778779
out whether ALT was pressed or not.
779780

781+
If the terminal supports the modifyOtherKeys mode and it has been enabled,
782+
then Vim can recognize more key combinations, see |modifyOtherKeys| below.
783+
780784
By default Vim assumes that pressing the ALT key sets the 8th bit of a typed
781785
character. Most decent terminals can work that way, such as xterm, aterm and
782786
rxvt. If your <A-k> mappings don't work it might be that the terminal is
@@ -814,7 +818,31 @@ on the terminal; that's a good last resource in case you want to send ESC when
814818
using other applications but not when inside Vim.
815819

816820

817-
1.11 MAPPING AN OPERATOR *:map-operator*
821+
1.11 MAPPING IN modifyOtherKeys mode *modifyOtherKeys*
822+
823+
Xterm and a few other terminals can be put in a mode where keys with modifiers
824+
are sent with a special escape code. Vim recognizes these codes and can then
825+
make a difference between CTRL-H and Backspace, even when Backspace sends the
826+
character 8. And many more special keys.
827+
828+
For xterm modifyOtherKeys is enabled in the builtin termcap entry. If this is
829+
not used you can enable modifyOtherKeys with these lines in your vimrc: >
830+
let &t_TI = "\<Esc>[>4;2m"
831+
let &t_TE = "\<Esc>[>4;m"
832+
833+
In case the modifyOtherKeys mode causes problems you can disable it: >
834+
let &t_TI = ""
835+
let &t_TE = ""
836+
It does not take effect immediately. To have this work without restarting Vim
837+
execute a shell command, e.g.: `!ls`
838+
839+
A known side effect effect is that in Insert mode the raw escape sequence is
840+
inserted after the CTRL-V key. This can be used to check whether
841+
modifyOtherKeys is enabled: In Insert mode type CTRL-V CTRL-V, if you get
842+
one byte then modifyOtherKeys is off, if you get <1b>27;5;118~ then it is on.
843+
844+
845+
1.12 MAPPING AN OPERATOR *:map-operator*
818846

819847
An operator is used before a {motion} command. To define your own operator
820848
you must create mapping that first sets the 'operatorfunc' option and then

src/term.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,8 @@ static struct builtin_term builtin_termcaps[] =
912912
{(int)KS_TE, IF_EB("\033[2J\033[?47l\0338",
913913
ESC_STR "[2J" ESC_STR_nc "[?47l" ESC_STR_nc "8")},
914914
# endif
915+
{(int)KS_CTI, IF_EB("\033[>4;2m", ESC_STR_nc "[>4;2m")},
916+
{(int)KS_CTE, IF_EB("\033[>4;m", ESC_STR_nc "[>4;m")},
915917
{(int)KS_CIS, IF_EB("\033]1;", ESC_STR "]1;")},
916918
{(int)KS_CIE, "\007"},
917919
{(int)KS_TS, IF_EB("\033]2;", ESC_STR "]2;")},

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
2194,
744746
/**/
745747
2193,
746748
/**/

0 commit comments

Comments
 (0)