Loading ...
Sorry, an error occurred while loading the content.

Map, meta key

Expand Messages
  • Donald Allen
    I am aware that issues with using the construct with map has provoked a lot of discussion. I freely admit that I have not read all of it
    Message 1 of 1 , Mar 14, 2013
    • 0 Attachment
      I am aware that issues with using the <M-something> construct with map
      has provoked a lot of discussion. I freely admit that I have not read
      all of it carefully, or even much of it. But I thought I'd
      report what I'd found from trying to resolve my own problem with this;
      perhaps it will help someone else. If what I'm about to say has
      already been said, use your delete key, or maybe backspace :-)

      I am running vim, not gvim, on an x86_64 Arch Linux system. I run X
      with dwm from suckless.org; no desktop system. I run vim in the
      terminal emulator from suckless, st. I tried

      map <M-j> <C-w>j

      as well as the obvious other three. This did not work. I did some
      digging and found discussion on this list about various codes that get
      sent by various keyboards. I have a standard US Lenovo keyboard. I ran
      xev to see what X thought the keyboard was sending, and pressing the
      left-hand alt key produced, wonder of wonders

      KeyPress event, serial 32, synthetic NO, window 0x2000001,
      root 0x24a, subw 0x0, time 6772607, (606,476), root:(607,492),
      state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
      XLookupString gives 0 bytes:
      XmbLookupString gives 0 bytes:
      XFilterEvent returns: False

      The j key produced something similarly expectable. So my keyboard is
      not the problem. Reading the vim documentation and some other
      material, I realized that I could see what
      vim was receiving, using c-v. What I got was ^[j when I pressed the
      left-hand alt key and 'j'; vim is seeing escape-j. Changing the map
      command in my .vimrc to

      map ^[j <C-w>j

      did the trick.

      I'm by no means an expert on termcap and terminfo, but I know what
      they do. On a hunch, I tried running vim in xterm, rather than st, and

      map ^[j <C-w>j

      did not work, but

      map <M-j> <C-w>j


      rxvt behaves the same way st does (you get the escape).

      Conclusion: as Bram has said, vim can only deal with what it sees.
      There's stuff between your keyboard and vim, and if it does something
      other than what you expect, the results won't be what you expect. In
      this case,
      knowing what your terminal emulator does matters a lot.

      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    Your message has been successfully submitted and would be delivered to recipients shortly.