In the last weeks I'm trying terminator as my terminal emulator (instead of the old and good xterm), and even though the experience is better, there's an annoying detail: all mappings involving alt don't work at all.

For example, I took these mappings from this reddit:

nnoremap <A-j> :m+<CR>==
nnoremap <A-k> :m-2<CR>==
nnoremap <A-h> <<
nnoremap <A-l> >>
inoremap <A-j> <Esc>:m+<CR>==gi
inoremap <A-k> <Esc>:m-2<CR>==gi
inoremap <A-h> <Esc><<`]a
inoremap <A-l> <Esc>>>`]a
vnoremap <A-j> :m'>+<CR>gv=gv
vnoremap <A-k> :m-2<CR>gv=gv
vnoremap <A-h> <gv
vnoremap <A-l> >gv
nnoremap <A-S-l> viwxp`[v`]
nnoremap <A-S-h> viwxhhp`[v`]
inoremap <A-S-l> <Esc>viwxp`[v`]
inoremap <A-S-h> <Esc>viwxhhp`[v`]
vnoremap <A-S-l> xp`[v`]
vnoremap <A-S-h> xhhp`[v`]

that allow to just "drag" the current line above or below, or indent it to the left or right with just alt plus the usual keys for movement: j, k, h, l.

Well, all these mappings don't work if I use terminator (but they do if I use xterm).

Is this a normal problem with terminator?

1 Answer 1


Experimenting with Ubuntu 16.04, terminator claims its TERM to be xterm, but sends different codes than xterm. For example, alt+j in terminator is 0x1b 0x6a, but on xterm it is 0xc3 0xaa. I think 0xc3 0xaa is utf-8 for ê.

Looking at the man page for xterm, it looks like altSendsEscape defaults to false, so the alt key makes an 8-bit character by default (that is then getting encoded to utf-8 for some reason?), whereas if set to true, it sends the escape (0x1b) followed by the unmodified character.

Vim's :help <A- indicates that Vim expects the 8-bit encoding for meta chars. This means it is compatible with the default settings in xterm, but not terminator (nor several others that behave the same way, like urxvt)

See also https://vi.stackexchange.com/a/1928/227 where this behavior is taken advantage of, though this doesn't help your use-case.

Based on https://stackoverflow.com/a/15399297/4504704, you can re-write your mappings to rely on the escape, for example:

nnoremap <ESC>j :m+<CR>==

This however has the downside that you'll have to wait a while after pressing escape before typing any characters mapped this way, because Vim won't be able to tell the difference between you hitting escape and then j (to move down) vs pressing alt+j.

  • 2
    Just found a better answer to this same question over on stack overflow: stackoverflow.com/a/10216459/4504704. Looks to cover the same info but with better detail.
    – John O'M.
    Apr 11, 2017 at 5:10
  • Thank you John. The link from stackoverflow that you posted in your comment solved my issue. I will post any issue that could arise as a side effect.
    – Nicolás
    Apr 11, 2017 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.