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

Unable to use Alt in shortcut key in VIM under linux

Expand Messages
  • Edward L. Fox
    Hi VIMmers, A friend encountered a problem in using VIM under Linux. He said, Either in VIM 7 or VIM 6.3, gVIM or VIM, every shortcut key with Alt key never
    Message 1 of 3 , May 2, 2005
      Hi VIMmers,

      A friend encountered a problem in using VIM under Linux.

      He said,

      "Either in VIM 7 or VIM 6.3, gVIM or VIM, every shortcut key with Alt key
      never works properly. Some of them produce strange phonetic symbol, some of
      them do nothing at all."

      "For example, I have mapped Alt + p as inputing 'i' in insert mode. When I
      press Alt + p in insert mode, a letter 'p' appeares."

      "For another example, I have mapped Alt + p as insertting javadoc-style
      comment. When I press Alt + p in normal mode, nothing happens."

      "But the same configuration works fine in Windows."

      "My console is mlterm, I choose Esc for meta key output (it doesn't work
      either if I don't choose Esc)."

      "This problem may have nothing to do with console. I tried rxvt and it
      didn't help either. Neither did gVIM."

      "What may probably causes the strange problem?"

      "I'm so upset about that. Because I nearly loose half of the possible
      shortcut keys. The shortage of shortcut keys really bothers me so much."


      I can't solve the problem. Waiting for your help... Thanks very much.


      Regards,


      Edward L. Fox
    • A. J. Mechelynck
      ... Alt + printable letter is not portable. On some systems it produces the same character with the high bit (0x80) on. On other systems it produces nothing
      Message 2 of 3 , May 2, 2005
        Edward L. Fox wrote:
        > Hi VIMmers,
        >
        > A friend encountered a problem in using VIM under Linux.
        >
        > He said,
        >
        > "Either in VIM 7 or VIM 6.3, gVIM or VIM, every shortcut key with Alt key
        > never works properly. Some of them produce strange phonetic symbol, some of
        > them do nothing at all."
        >
        > "For example, I have mapped Alt + p as inputing 'i' in insert mode. When I
        > press Alt + p in insert mode, a letter 'p' appeares."
        >
        > "For another example, I have mapped Alt + p as insertting javadoc-style
        > comment. When I press Alt + p in normal mode, nothing happens."
        >
        > "But the same configuration works fine in Windows."
        >
        > "My console is mlterm, I choose Esc for meta key output (it doesn't work
        > either if I don't choose Esc)."
        >
        > "This problem may have nothing to do with console. I tried rxvt and it
        > didn't help either. Neither did gVIM."
        >
        > "What may probably causes the strange problem?"
        >
        > "I'm so upset about that. Because I nearly loose half of the possible
        > shortcut keys. The shortage of shortcut keys really bothers me so much."
        >
        >
        > I can't solve the problem. Waiting for your help... Thanks very much.
        >
        >
        > Regards,
        >
        >
        > Edward L. Fox
        >
        >
        >
        >
        Alt + printable letter is not portable. On some systems it produces the
        same character with the high bit (0x80) on. On other systems it produces
        nothing recognizable.

        Alt + special key (e.g. Alt+F1, Alt+Up, etc.) is somewhat more reliable,
        yet you still have to check its workings on any system where you want to
        use it.

        In general, the F keys (F1-F12) with or without any combination of
        Shift, Ctrl and Alt, are IIUC the keys most reliably recognised across
        systems (among the keys which don't already have a preset action in Vim).

        To check if a given key combination is recognised and as what, press it
        after Ctrl-V in Insert mode (or if you use Ctrl-V to paste, use Ctrl-Q
        instead). Depending on what Vim sees, you might see something like

        รข

        (one character not present in the 7-bit ASCII set), or something like

        <M-F2>

        (a key designation in <> notation). If you see nothing at all, the key
        is possibly "eaten" before Vim sees it.

        See also
        :help 'winaltkeys'
        :help termcap
        :help :set-termcap

        Note that most of the termcap codes (including the key codes) cannot be
        changed in the GUI.


        Best regards,
        Tony.
      • A. J. Mechelynck
        ... I don t know anything about Emacs. There are several methods to read keyboard data on a given operating system. AFAICT, Vim uses cooked input which is
        Message 3 of 3 , May 2, 2005
          Edward L. Fox wrote:
          > Hi Tony,
          >
          > Thanks very much.
          >
          > So you meant that the key was eaten by the system, the window manager or
          > something else so it can't be handled by the application. I'm still curious
          > about how does Emacs manage to get the eaten key code to support its
          > ridiculous shortcut keys.
          >
          >
          > Regards,
          >
          >
          > Edward L. Fox

          I don't know anything about Emacs. There are several methods to read
          keyboard data on a given operating system. AFAICT, Vim uses "cooked"
          input which is most reliable, espectally for text, across systems and
          languages. I don't know if Emacs uses "raw" input or some other method.
          (One of the problems of raw input is that the program must do itself
          what the keyboard driver is doing, or it will be OK on a US keyboard but
          maybe unwittingly swap A and Q, W and Z on a French keyboard etc.)

          A property (call it a bug or a feature) of "cooked" input is that
          several keys may become "synonymous", e.g., ^I and Tab, ^M and Enter, ^H
          and Backspace, etc. This means that in Vim you cannot map Ctrl-I and Tab
          (or Ctrl-M and Enter etc.) independently from each other.


          Best regards,
          Tony.
        Your message has been successfully submitted and would be delivered to recipients shortly.