How to get the key name to be coded for keymap in vimrc?
In Emacs, I can press Ctrl-h, k, to describe a key. I can get the key name even it's undefined, e.g.,
C-x <C-M-end> is undefined
Thus, I got to know the key name is C-x <C-M-end>
.
But how can you get the key name for Vim?
I want to setup a keymap for Ctrl-Shift-V and Shift-Insert, but what the code shall I have to use?
Is it possible to get the key name on the fly?
vim keymap
add a comment |
In Emacs, I can press Ctrl-h, k, to describe a key. I can get the key name even it's undefined, e.g.,
C-x <C-M-end> is undefined
Thus, I got to know the key name is C-x <C-M-end>
.
But how can you get the key name for Vim?
I want to setup a keymap for Ctrl-Shift-V and Shift-Insert, but what the code shall I have to use?
Is it possible to get the key name on the fly?
vim keymap
add a comment |
In Emacs, I can press Ctrl-h, k, to describe a key. I can get the key name even it's undefined, e.g.,
C-x <C-M-end> is undefined
Thus, I got to know the key name is C-x <C-M-end>
.
But how can you get the key name for Vim?
I want to setup a keymap for Ctrl-Shift-V and Shift-Insert, but what the code shall I have to use?
Is it possible to get the key name on the fly?
vim keymap
In Emacs, I can press Ctrl-h, k, to describe a key. I can get the key name even it's undefined, e.g.,
C-x <C-M-end> is undefined
Thus, I got to know the key name is C-x <C-M-end>
.
But how can you get the key name for Vim?
I want to setup a keymap for Ctrl-Shift-V and Shift-Insert, but what the code shall I have to use?
Is it possible to get the key name on the fly?
vim keymap
vim keymap
asked Jan 20 '11 at 3:20
Xiè JìléiXiè Jìléi
6,9962072107
6,9962072107
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
The closest I can find to describe-key
(Ctrl+H, K) is the :map
command. It will list all mappings.
You can also run :map <key name>
, but you have to specify <key>
using the special syntax listed in
key-notation.
Or you can try :map
Ctrl+V<key>
, which should let you just press the key rather than needing to use the special syntax.
So to bind Ctrl+Shift+V, try this:
:map <C-S-v> whatever
or
:map
Ctrl+V Ctrl+Shift+V whatever
But make sure that your terminal program doesn't already use this for something special like paste, otherwise Vim will never see the key press.
Also see map-alt-keys, which helps explain whether your Alt key should be written as <M-x>
or <A-x>
.
It's Ctrl-h,k, not Ctrl-X,k which means kill buffer.
– Xiè Jìléi
Jan 20 '11 at 4:13
Sorry, fixed that.
– Mikel
Jan 20 '11 at 4:16
I'm not sure ifM
orA
will be mapped toAlt
. But<M-h>, <M-l>
just don't work. I don't know whether the key name is invalid, or the key events haven't been sent to Vim. No log, no clue.
– Xiè Jìléi
Jan 20 '11 at 4:19
Yes,Alt
is difficult, because most terminals sendESC
thenx
whenAlt+x
is pressed, and how does Vim know you didn't pressESC
thenx
. BasicallyAlt
only works in Gvim.
– Mikel
Jan 20 '11 at 4:27
add a comment |
To find out what a key or key combination outputs in Vim, I usually open a blank buffer with ":enew
", enter insert mode, press control-v, then the key or key combination I want to identify. This control-v trick can also work on the :-command line, so defining mappings for testing is fairly easy. For example, ":map
", control-v and the key combination, " :echo 'it works'
".
add a comment |
Just type Ctrl+V on-the-fly and the keys you wish to press. If you don't found the result expected (like for instance <c-space>
, <c-cr>
, <M-i>
, ...) it just means you are using vim and not gvim. The way vim understands the keys typed is tied to the configuration of your terminal(s). gvim uses its own definitions, there is thus nothing to configure.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f235484%2fhow-to-get-the-key-name-to-be-coded-for-keymap-in-vimrc%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
The closest I can find to describe-key
(Ctrl+H, K) is the :map
command. It will list all mappings.
You can also run :map <key name>
, but you have to specify <key>
using the special syntax listed in
key-notation.
Or you can try :map
Ctrl+V<key>
, which should let you just press the key rather than needing to use the special syntax.
So to bind Ctrl+Shift+V, try this:
:map <C-S-v> whatever
or
:map
Ctrl+V Ctrl+Shift+V whatever
But make sure that your terminal program doesn't already use this for something special like paste, otherwise Vim will never see the key press.
Also see map-alt-keys, which helps explain whether your Alt key should be written as <M-x>
or <A-x>
.
It's Ctrl-h,k, not Ctrl-X,k which means kill buffer.
– Xiè Jìléi
Jan 20 '11 at 4:13
Sorry, fixed that.
– Mikel
Jan 20 '11 at 4:16
I'm not sure ifM
orA
will be mapped toAlt
. But<M-h>, <M-l>
just don't work. I don't know whether the key name is invalid, or the key events haven't been sent to Vim. No log, no clue.
– Xiè Jìléi
Jan 20 '11 at 4:19
Yes,Alt
is difficult, because most terminals sendESC
thenx
whenAlt+x
is pressed, and how does Vim know you didn't pressESC
thenx
. BasicallyAlt
only works in Gvim.
– Mikel
Jan 20 '11 at 4:27
add a comment |
The closest I can find to describe-key
(Ctrl+H, K) is the :map
command. It will list all mappings.
You can also run :map <key name>
, but you have to specify <key>
using the special syntax listed in
key-notation.
Or you can try :map
Ctrl+V<key>
, which should let you just press the key rather than needing to use the special syntax.
So to bind Ctrl+Shift+V, try this:
:map <C-S-v> whatever
or
:map
Ctrl+V Ctrl+Shift+V whatever
But make sure that your terminal program doesn't already use this for something special like paste, otherwise Vim will never see the key press.
Also see map-alt-keys, which helps explain whether your Alt key should be written as <M-x>
or <A-x>
.
It's Ctrl-h,k, not Ctrl-X,k which means kill buffer.
– Xiè Jìléi
Jan 20 '11 at 4:13
Sorry, fixed that.
– Mikel
Jan 20 '11 at 4:16
I'm not sure ifM
orA
will be mapped toAlt
. But<M-h>, <M-l>
just don't work. I don't know whether the key name is invalid, or the key events haven't been sent to Vim. No log, no clue.
– Xiè Jìléi
Jan 20 '11 at 4:19
Yes,Alt
is difficult, because most terminals sendESC
thenx
whenAlt+x
is pressed, and how does Vim know you didn't pressESC
thenx
. BasicallyAlt
only works in Gvim.
– Mikel
Jan 20 '11 at 4:27
add a comment |
The closest I can find to describe-key
(Ctrl+H, K) is the :map
command. It will list all mappings.
You can also run :map <key name>
, but you have to specify <key>
using the special syntax listed in
key-notation.
Or you can try :map
Ctrl+V<key>
, which should let you just press the key rather than needing to use the special syntax.
So to bind Ctrl+Shift+V, try this:
:map <C-S-v> whatever
or
:map
Ctrl+V Ctrl+Shift+V whatever
But make sure that your terminal program doesn't already use this for something special like paste, otherwise Vim will never see the key press.
Also see map-alt-keys, which helps explain whether your Alt key should be written as <M-x>
or <A-x>
.
The closest I can find to describe-key
(Ctrl+H, K) is the :map
command. It will list all mappings.
You can also run :map <key name>
, but you have to specify <key>
using the special syntax listed in
key-notation.
Or you can try :map
Ctrl+V<key>
, which should let you just press the key rather than needing to use the special syntax.
So to bind Ctrl+Shift+V, try this:
:map <C-S-v> whatever
or
:map
Ctrl+V Ctrl+Shift+V whatever
But make sure that your terminal program doesn't already use this for something special like paste, otherwise Vim will never see the key press.
Also see map-alt-keys, which helps explain whether your Alt key should be written as <M-x>
or <A-x>
.
edited Jan 20 '11 at 13:12
answered Jan 20 '11 at 3:56
MikelMikel
7,54013434
7,54013434
It's Ctrl-h,k, not Ctrl-X,k which means kill buffer.
– Xiè Jìléi
Jan 20 '11 at 4:13
Sorry, fixed that.
– Mikel
Jan 20 '11 at 4:16
I'm not sure ifM
orA
will be mapped toAlt
. But<M-h>, <M-l>
just don't work. I don't know whether the key name is invalid, or the key events haven't been sent to Vim. No log, no clue.
– Xiè Jìléi
Jan 20 '11 at 4:19
Yes,Alt
is difficult, because most terminals sendESC
thenx
whenAlt+x
is pressed, and how does Vim know you didn't pressESC
thenx
. BasicallyAlt
only works in Gvim.
– Mikel
Jan 20 '11 at 4:27
add a comment |
It's Ctrl-h,k, not Ctrl-X,k which means kill buffer.
– Xiè Jìléi
Jan 20 '11 at 4:13
Sorry, fixed that.
– Mikel
Jan 20 '11 at 4:16
I'm not sure ifM
orA
will be mapped toAlt
. But<M-h>, <M-l>
just don't work. I don't know whether the key name is invalid, or the key events haven't been sent to Vim. No log, no clue.
– Xiè Jìléi
Jan 20 '11 at 4:19
Yes,Alt
is difficult, because most terminals sendESC
thenx
whenAlt+x
is pressed, and how does Vim know you didn't pressESC
thenx
. BasicallyAlt
only works in Gvim.
– Mikel
Jan 20 '11 at 4:27
It's Ctrl-h,k, not Ctrl-X,k which means kill buffer.
– Xiè Jìléi
Jan 20 '11 at 4:13
It's Ctrl-h,k, not Ctrl-X,k which means kill buffer.
– Xiè Jìléi
Jan 20 '11 at 4:13
Sorry, fixed that.
– Mikel
Jan 20 '11 at 4:16
Sorry, fixed that.
– Mikel
Jan 20 '11 at 4:16
I'm not sure if
M
or A
will be mapped to Alt
. But <M-h>, <M-l>
just don't work. I don't know whether the key name is invalid, or the key events haven't been sent to Vim. No log, no clue.– Xiè Jìléi
Jan 20 '11 at 4:19
I'm not sure if
M
or A
will be mapped to Alt
. But <M-h>, <M-l>
just don't work. I don't know whether the key name is invalid, or the key events haven't been sent to Vim. No log, no clue.– Xiè Jìléi
Jan 20 '11 at 4:19
Yes,
Alt
is difficult, because most terminals send ESC
then x
when Alt+x
is pressed, and how does Vim know you didn't press ESC
then x
. Basically Alt
only works in Gvim.– Mikel
Jan 20 '11 at 4:27
Yes,
Alt
is difficult, because most terminals send ESC
then x
when Alt+x
is pressed, and how does Vim know you didn't press ESC
then x
. Basically Alt
only works in Gvim.– Mikel
Jan 20 '11 at 4:27
add a comment |
To find out what a key or key combination outputs in Vim, I usually open a blank buffer with ":enew
", enter insert mode, press control-v, then the key or key combination I want to identify. This control-v trick can also work on the :-command line, so defining mappings for testing is fairly easy. For example, ":map
", control-v and the key combination, " :echo 'it works'
".
add a comment |
To find out what a key or key combination outputs in Vim, I usually open a blank buffer with ":enew
", enter insert mode, press control-v, then the key or key combination I want to identify. This control-v trick can also work on the :-command line, so defining mappings for testing is fairly easy. For example, ":map
", control-v and the key combination, " :echo 'it works'
".
add a comment |
To find out what a key or key combination outputs in Vim, I usually open a blank buffer with ":enew
", enter insert mode, press control-v, then the key or key combination I want to identify. This control-v trick can also work on the :-command line, so defining mappings for testing is fairly easy. For example, ":map
", control-v and the key combination, " :echo 'it works'
".
To find out what a key or key combination outputs in Vim, I usually open a blank buffer with ":enew
", enter insert mode, press control-v, then the key or key combination I want to identify. This control-v trick can also work on the :-command line, so defining mappings for testing is fairly easy. For example, ":map
", control-v and the key combination, " :echo 'it works'
".
answered Jan 20 '11 at 6:15
HeptiteHeptite
14.8k54258
14.8k54258
add a comment |
add a comment |
Just type Ctrl+V on-the-fly and the keys you wish to press. If you don't found the result expected (like for instance <c-space>
, <c-cr>
, <M-i>
, ...) it just means you are using vim and not gvim. The way vim understands the keys typed is tied to the configuration of your terminal(s). gvim uses its own definitions, there is thus nothing to configure.
add a comment |
Just type Ctrl+V on-the-fly and the keys you wish to press. If you don't found the result expected (like for instance <c-space>
, <c-cr>
, <M-i>
, ...) it just means you are using vim and not gvim. The way vim understands the keys typed is tied to the configuration of your terminal(s). gvim uses its own definitions, there is thus nothing to configure.
add a comment |
Just type Ctrl+V on-the-fly and the keys you wish to press. If you don't found the result expected (like for instance <c-space>
, <c-cr>
, <M-i>
, ...) it just means you are using vim and not gvim. The way vim understands the keys typed is tied to the configuration of your terminal(s). gvim uses its own definitions, there is thus nothing to configure.
Just type Ctrl+V on-the-fly and the keys you wish to press. If you don't found the result expected (like for instance <c-space>
, <c-cr>
, <M-i>
, ...) it just means you are using vim and not gvim. The way vim understands the keys typed is tied to the configuration of your terminal(s). gvim uses its own definitions, there is thus nothing to configure.
edited Jan 20 '11 at 12:56
answered Jan 20 '11 at 10:49
Luc HermitteLuc Hermitte
1,52598
1,52598
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f235484%2fhow-to-get-the-key-name-to-be-coded-for-keymap-in-vimrc%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown