Wednesday, November 20, 2024

Re: Alt keys not sent to Vim :terminal

On Wed, 20 Nov 2024 14:05:11 -0500
Enan Ajmain <3nan.ajmain@gmail.com> wrote:
> 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.

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

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/vim_use/20241120155715.0000781d%40gmail.com.

No comments: