How to get the key name to be coded for keymap in vimrc?












8















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?










share|improve this question



























    8















    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?










    share|improve this question

























      8












      8








      8


      3






      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?










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 20 '11 at 3:20









      Xiè JìléiXiè Jìléi

      6,9512072107




      6,9512072107






















          3 Answers
          3






          active

          oldest

          votes


















          1














          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 :mapCtrl+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



          :mapCtrl+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>.






          share|improve this answer


























          • 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 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





















          3














          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'".






          share|improve this answer































            0














            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.






            share|improve this answer

























              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
              });


              }
              });














              draft saved

              draft discarded


















              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









              1














              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 :mapCtrl+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



              :mapCtrl+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>.






              share|improve this answer


























              • 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 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


















              1














              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 :mapCtrl+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



              :mapCtrl+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>.






              share|improve this answer


























              • 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 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
















              1












              1








              1







              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 :mapCtrl+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



              :mapCtrl+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>.






              share|improve this answer















              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 :mapCtrl+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



              :mapCtrl+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>.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Jan 20 '11 at 13:12

























              answered Jan 20 '11 at 3:56









              MikelMikel

              7,53013434




              7,53013434













              • 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 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





















              • 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 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



















              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















              3














              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'".






              share|improve this answer




























                3














                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'".






                share|improve this answer


























                  3












                  3








                  3







                  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'".






                  share|improve this answer













                  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'".







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 20 '11 at 6:15









                  HeptiteHeptite

                  14.8k54157




                  14.8k54157























                      0














                      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.






                      share|improve this answer






























                        0














                        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.






                        share|improve this answer




























                          0












                          0








                          0







                          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.






                          share|improve this answer















                          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.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Jan 20 '11 at 12:56

























                          answered Jan 20 '11 at 10:49









                          Luc HermitteLuc Hermitte

                          1,52598




                          1,52598






























                              draft saved

                              draft discarded




















































                              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.




                              draft saved


                              draft discarded














                              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





















































                              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







                              Popular posts from this blog

                              Probability when a professor distributes a quiz and homework assignment to a class of n students.

                              Aardman Animations

                              Are they similar matrix