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

Re: Mapping alt keys on linux konsole

Expand Messages
  • Ananth Devulapalli
    Hello tony: Thanks to your post here, http://marc.theaimsgroup.com/?l=vim&m=107126194523686&w=2 I was able to map keys. There are two ways one can go
    Message 1 of 10 , Jan 13, 2005
    View Source
    • 0 Attachment
      Hello tony:

      Thanks to your post here,
      http://marc.theaimsgroup.com/?l=vim&m=107126194523686&w=2
      I was able to map <alt> keys.

      There are two ways one can go about mapping <alt> keys
      1) Enter the key in raw mode using <C-V>. Suppose i
      need to map
      <alt-f> to iHello<Esc>, I would do the following:
      :nmap <C-V><alt-f> iHello<Esc>
      Here <C-V> is used to enter the key sequence in raw
      mode.

      2) Using set
      a) set <M-f>=<C-V><alt-f>
      First set <M-f> (4 chracters) to the raw mode using
      <C-V><Alt-f>.
      b) :nmap <M-f> iHello<Esc>
      But this requires one more step.

      Now if one does :map, the mapping's {lhs} will be
      <Esc>f, since alt sends <Esc> as its first key. In
      normal mode if one presses <Esc> and then f, that will
      be equivalent to <M-f>.

      Even though, I am able to map alt key combinations, I
      am not able to use predefined mappings. For eg., i use
      vim-latex-suite for editing tex files, which has
      polymorphic <Alt-L> key binding which is very useful.
      It works like a breeze in Gvim, but dumbs out on
      Konsole/xterm. Will be asking folks over there.

      thanks all for your help.
      -Ananth




      __________________________________
      Do you Yahoo!?
      Take Yahoo! Mail with you! Get it on your mobile phone.
      http://mobile.yahoo.com/maildemo
    • Antoine J. Mechelynck
      Ananth Devulapalli wrote: [...] ... [...] Using the :set method (method 2 in your post), and with a mapping whose {lhs} is set to (i.e., less-than, M,
      Message 2 of 10 , Jan 14, 2005
      View Source
      • 0 Attachment
        Ananth Devulapalli wrote:
        [...]
        > Now if one does :map, the mapping's {lhs} will be
        > <Esc>f, since alt sends <Esc> as its first key. In
        > normal mode if one presses <Esc> and then f, that will
        > be equivalent to <M-f>.
        [...]

        Using the ":set" method (method 2 in your post), and with a mapping
        whose {lhs} is set to <M-f> (i.e., less-than, M, dash, f, greater-than)
        Vim ought to be able to distinguish between <Esc> followed by f typed on
        the keyboard (which should not be mapped), and <Esc>f entered as the
        keyboard code for Alt-f (which should be mapped), provided that you set
        your timeouts correctly. See

        :help 'timeout'
        :help 'timeoutlen'
        :help 'ttimeout'
        :help 'ttimeoutlen'

        and also at the bottom of this post.

        It may be necessary to execute the ":set" statement before defining the
        mapping; but that ought not to be a problem with plugins, since they are
        normally sourced after your vimrc (see ":help startup" and/or the output
        of ":scriptnames"). Thus, IIUC, you could make it work by placing, let's
        say,

        runtime macros/keybind.vim

        in your vimrc before any mappings, and creating a file named
        ~/.vim/macros/keybind.vim and containing

        if has("gui_running")
        finish
        endif
        set <M-a>=^[a
        set <M-b>=^[b
        set <M-c>=^[c

        etc., where ^[ is obtained by pressing Ctrl-V followed by <Esc>. (Create
        the needed directories if they don't exist yet.) (I'm suggesting to
        place these keycode definitions in a separate script to avoid cluttering
        the vimrc.)

        Since I'm a slow typer using several multicharacter mappings, I use

        set timeout timeoutlen=5000 ttimeoutlen=500

        in my vimrc. These timeouts are in milliseconds: the faster you type,
        the shorter timeouts you should use. Conversely, if you're talking with
        Vim over a slow communication line, you may need to increase the timeouts.

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