Macvim: option (alt) not works in :terminal

Created on 22 Feb 2019  路  4Comments  路  Source: macvim-dev/macvim

Reproduce

:terminal
echo hello<CR>
<M-.>

not show 'hello'

but it works when macvim run in Terminal

Input

Most helpful comment

Finnally锛孖 found a solution:

" I don't known why this line not work..., it seems a bug
"tnoremap <M-.> <C-w>:<C-u>call term_sendkeys(bufnr('%'), "\<Esc>.")<CR>
tnoremap <silent> <M-.> <C-w>:call <SID>tmap_meta('.')<CR>
function s:tmap_meta(key)
    call term_sendkeys(bufnr('%'), "\<Esc>" . a:key)
endfunction

All 4 comments

Hmm what's the issue here? What shell are you using and what were you expecting?

Also, do you have set macmeta? Does setting that help?

Finnally锛孖 found a solution:

" I don't known why this line not work..., it seems a bug
"tnoremap <M-.> <C-w>:<C-u>call term_sendkeys(bufnr('%'), "\<Esc>.")<CR>
tnoremap <silent> <M-.> <C-w>:call <SID>tmap_meta('.')<CR>
function s:tmap_meta(key)
    call term_sendkeys(bufnr('%'), "\<Esc>" . a:key)
endfunction

Oh I see, basically the shell you were using was expecting Meta-<key> sequence to be encoding as <Esc> + <key>, which is how most shells work, but in GVim (and MacVim under macmeta) it uses 8-bit encoding (do :h xterm-8bit) so it's not really compatible.

This ties to a larger ongoing issue about how Vim should be handling meta keys and would need some thought and collaboration with Vim to figure this out. I think for now you will need to keep your workaround.

Keeping this issue open for tracking.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yamini-krishnamurthy picture yamini-krishnamurthy  路  5Comments

raimue picture raimue  路  4Comments

bdarfler picture bdarfler  路  4Comments

9mm picture 9mm  路  4Comments

itsayellow picture itsayellow  路  4Comments