patch 9.1.0058: Cannot map Super Keys in GTK UI
Problem: Cannot map Super Keys in GTK UI
(Casey Tucker)
Solution: Enable Super Key mappings in GTK using <D-Key>
(Casey Tucker)
As a developer who works in both Mac and Linux using the same keyboard,
it can be frustrating having to remember different key combinations or
having to rely on system utilities to remap keys.
This change allows `<D-z>` `<D-x>` `<D-c>` `<D-v>` etc. to be recognized
by the `map` commands, along with the `<D-S-...>` shifted variants.
```vimrc
if has('gui_gtk')
nnoremap <D-z> u
nnoremap <D-S-Z> <C-r>
vnoremap <D-x> "+d
vnoremap <D-c> "+y
cnoremap <D-v> <C-R>+
inoremap <D-v> <C-o>"+gP
nnoremap <D-v> "+P
vnoremap <D-v> "-d"+P
nnoremap <D-s> :w<CR>
inoremap <D-s> <C-o>:w<CR>
nnoremap <D-w> :q<CR>
nnoremap <D-q> :qa<CR>
nnoremap <D-t> :tabe<CR>
nnoremap <D-S-T> :vs#<CR><C-w>T
nnoremap <D-a> ggVG
vnoremap <D-a> <ESC>ggVG
inoremap <D-a> <ESC>ggVG
nnoremap <D-f> /
nnoremap <D-g> n
nnoremap <D-S-G> N
vnoremap <D-x> "+x
endif
```
closes: #12698
Signed-off-by: Casey Tucker <dctucker@hotmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 9b706ba..88cf642 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -1,4 +1,4 @@
-*builtin.txt* For Vim version 9.1. Last change: 2024 Jan 23
+*builtin.txt* For Vim version 9.1. Last change: 2024 Jan 25
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -3470,7 +3470,7 @@
32 mouse double click
64 mouse triple click
96 mouse quadruple click (== 32 + 64)
- 128 command (Macintosh only)
+ 128 command (Mac) or super (GTK)
Only the modifiers that have not been included in the
character itself are obtained. Thus Shift-a results in "A"
without a modifier. Returns 0 if no modifiers are used.
diff --git a/runtime/doc/intro.txt b/runtime/doc/intro.txt
index 185796f..120d65d 100644
--- a/runtime/doc/intro.txt
+++ b/runtime/doc/intro.txt
@@ -1,4 +1,4 @@
-*intro.txt* For Vim version 9.1. Last change: 2023 Nov 18
+*intro.txt* For Vim version 9.1. Last change: 2024 Jan 25
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -475,7 +475,7 @@
<C-...> control-key *control* *ctrl* *<C-*
<M-...> alt-key or meta-key *meta* *alt* *<M-*
<A-...> same as <M-...> *<A-*
-<D-...> command-key (Macintosh only) *<D-*
+<D-...> command-key (Mac) / super (GTK) *<D-*
<t_xx> key with "xx" entry in termcap
-----------------------------------------------------------------------
diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt
index 7d4d530..cf83ffc 100644
--- a/runtime/doc/map.txt
+++ b/runtime/doc/map.txt
@@ -1,4 +1,4 @@
-*map.txt* For Vim version 9.1. Last change: 2024 Jan 04
+*map.txt* For Vim version 9.1. Last change: 2024 Jan 25
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -21,9 +21,10 @@
1.9 Using mappings |map-typing|
1.10 Mapping alt-keys |:map-alt-keys|
1.11 Mapping meta-keys |:map-meta-keys|
- 1.12 Mapping in modifyOtherKeys mode |modifyOtherKeys|
- 1.13 Mapping with Kitty keyboard protocol |kitty-keyboard-protocol|
- 1.14 Mapping an operator |:map-operator|
+ 1.12 Mapping super-keys or command keys |:map-super-keys|
+ 1.13 Mapping in modifyOtherKeys mode |modifyOtherKeys|
+ 1.14 Mapping with Kitty keyboard protocol |kitty-keyboard-protocol|
+ 1.15 Mapping an operator |:map-operator|
2. Abbreviations |abbreviations|
3. Local mappings and functions |script-local|
4. User-defined commands |user-commands|
@@ -985,8 +986,17 @@
in Insert mode: >
:imap <T-b> terrible
+1.12 MAPPING SUPER-KEYS or COMMAND-KEYS *:map-super-keys* *:map-cmd-key*
-1.12 MAPPING IN modifyOtherKeys mode *modifyOtherKeys*
+The Super modifier is available in GUI mode (when |gui_running| is 1) for
+GVim on Linux and MacVim on Mac OS. If you're on a Mac, this represents the
+Command key, on Linux with the GTK GUI it represents the Super key.
+The character "D" is used for the Super / Command modifier.
+
+For example, to map Command-b in Insert mode: >
+ :imap <D-b> barritone
+
+1.13 MAPPING IN modifyOtherKeys mode *modifyOtherKeys*
Xterm and a few other terminals can be put in a mode where keys with modifiers
are sent with a special escape code. Vim recognizes these codes and can then
@@ -1048,7 +1058,7 @@
Insert mode to avoid every key with a modifier causing Insert mode to end.
-1.13 MAPPING WITH KITTY KEYBOARD PROTOCOL *kitty-keyboard-protocol*
+1.14 MAPPING WITH KITTY KEYBOARD PROTOCOL *kitty-keyboard-protocol*
If the value of 'term' contains "kitty" then Vim will send out an escape
sequence to enable the Kitty keyboard protocol. This can be changed with the
@@ -1075,7 +1085,7 @@
previous state is unknown
-1.14 MAPPING AN OPERATOR *:map-operator*
+1.15 MAPPING AN OPERATOR *:map-operator*
An operator is used before a {motion} command. To define your own operator
you must create a mapping that first sets the 'operatorfunc' option and then
diff --git a/runtime/doc/tags b/runtime/doc/tags
index 809c6fd..9a89916 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -2873,6 +2873,7 @@
:map-arguments map.txt /*:map-arguments*
:map-buffer map.txt /*:map-buffer*
:map-cmd map.txt /*:map-cmd*
+:map-cmd-key map.txt /*:map-cmd-key*
:map-commands map.txt /*:map-commands*
:map-expression map.txt /*:map-expression*
:map-local map.txt /*:map-local*
@@ -2885,6 +2886,7 @@
:map-special map.txt /*:map-special*
:map-special-chars map.txt /*:map-special-chars*
:map-special-keys map.txt /*:map-special-keys*
+:map-super-keys map.txt /*:map-super-keys*
:map-undo map.txt /*:map-undo*
:map-unique map.txt /*:map-unique*
:map-verbose map.txt /*:map-verbose*