Alt keys not sent to Vim :terminal

9 views
Skip to first unread message

Enan Ajmain

unread,
Nov 20, 2024, 2:05:21 PM11/20/24
to Vim Users
Hi,

I'm in Windows. In Linux, I always use Tmux for my terminal use cases.
But since Tmux doesn't exist in Windows, I wanted to use the embedded
terminal in Vim. It works great. Except --

The alt keys are sending accent letters. For example, I am using Clink,
which adds GNU readline-like features to Command Prompt. So I can use
Alt-f and Alt-b to move cursor one word forward and backward. It works
in external terminal emulator. But it doesn't work in Vim's embedded
terminal.

C:> this is a word æâ

Above you can see the accented characters æ and â where I pressed Alt-b
and Alt-f respectively. This issue exists in both TUI Vim and GVim.

How can I fix this issue?

Note that I checked with pressing <Ctrl-v><Alt-f> in insert mode in a
non-terminal buffer and it indeed put æ. So I'm thinking if I can send
some other code corresponding to Alt-f, it will work, but I'm not sure.

--
Enan

P.S. Ctrl keys work fine. Ctrl-a/e moves the cursor to the start/end of
the line.

Enan Ajmain

unread,
Nov 20, 2024, 3:57:28 PM11/20/24
to Vim Users
As usual, I got the solution right after I asked for help. I needed to
send Esc for Alt keys:


for i in range(65,90) + range(97,122)
let c = nr2char(i)
exec "tnoremap <A-".c."> <Esc>".c
exec "tnoremap <A-C-".c."> <Esc><C-".c.">"
endfor

--
Enan
Reply all
Reply to author
Forward
0 new messages