Win32 Vim inside MSYS Tmux doesn't interpret C-h

11 views
Skip to first unread message

Enan Ajmain

unread,
Jul 8, 2023, 12:16:15 PM7/8/23
to vim...@googlegroups.com
This is an edgecase. I am using win32 version of Vim (built with gcc of
mingw-w64) inside Tmux provided by msys. In it C-h isn't interpreted as
it is done outside Tmux. I have this keymap:

nnoremap <C-h> <C-w>h

And it doesn't take effect in win32-vim in tmux.

I also have an unix version of vim, built with gcc from msys. By "unix
version," I mean it runs on msys shell with its unix layer. This
version of vim, unix-vim, interprets <C-h> inside tmux properly. Vim
inside Tmux on native Linux also interprets <C-h> properly.

Although few if anyone use win32 Vim inside Tmux, so this issue is not
really an issue, but I am curious as to what's going on, if anyone here
can shed some light.

--
Enan

Christian Brabandt

unread,
Jul 8, 2023, 12:57:10 PM7/8/23
to vim...@googlegroups.com

On Sa, 08 Jul 2023, Enan Ajmain wrote:

> This is an edgecase. I am using win32 version of Vim (built with gcc of
> mingw-w64) inside Tmux provided by msys. In it C-h isn't interpreted as
> it is done outside Tmux. I have this keymap:
>
> nnoremap <C-h> <C-w>h
>
> And it doesn't take effect in win32-vim in tmux.

Have you tried explicitly typing <C-h>?

> I also have an unix version of vim, built with gcc from msys. By "unix
> version," I mean it runs on msys shell with its unix layer. This
> version of vim, unix-vim, interprets <C-h> inside tmux properly. Vim
> inside Tmux on native Linux also interprets <C-h> properly.
>
> Although few if anyone use win32 Vim inside Tmux, so this issue is not
> really an issue, but I am curious as to what's going on, if anyone here
> can shed some light.

Well, it may be, that Vim just receives <C-?> instead of <C-h>. Vim even
has its own method of fixing this by using the :fixdel command. Nowadays
one usually uses stty erase ^? or similar to configure the backspace
thing (or one configures the terminal directly what it should send for
backspace).

Long are the times gone, when I needed to fiddle with that ;)

So I would first try inside vim, what is actually printed when typing in
insert mode <C-V><Backspace> and from there we can continue.

Best,
Christian
--
Zu viel Zeit mit Studieren verbringen, ist Faulheit; es nur als
Schmuck zu verwenden - Affektiertheit; nur danach zu urteilen -
Gelehrtenwahn.
-- Francis Bacon

Enan Ajmain

unread,
Jul 8, 2023, 1:47:07 PM7/8/23
to Christian Brabandt, vim...@googlegroups.com
On Sat, 8 Jul 2023 18:57:01 +0200
Christian Brabandt <cbl...@256bit.org> wrote:
> On Sa, 08 Jul 2023, Enan Ajmain wrote:
>
> > This is an edgecase. I am using win32 version of Vim (built with gcc of
> > mingw-w64) inside Tmux provided by msys. In it C-h isn't interpreted as
> > it is done outside Tmux. I have this keymap:
> >
> > nnoremap <C-h> <C-w>h
> >
> > And it doesn't take effect in win32-vim in tmux.
>
> Have you tried explicitly typing <C-h>?
>
> > I also have an unix version of vim, built with gcc from msys. By "unix
> > version," I mean it runs on msys shell with its unix layer. This
> > version of vim, unix-vim, interprets <C-h> inside tmux properly. Vim
> > inside Tmux on native Linux also interprets <C-h> properly.
> >
> > Although few if anyone use win32 Vim inside Tmux, so this issue is not
> > really an issue, but I am curious as to what's going on, if anyone here
> > can shed some light.
>
> Well, it may be, that Vim just receives <C-?> instead of <C-h>. Vim even
> has its own method of fixing this by using the :fixdel command. Nowadays
> one usually uses stty erase ^? or similar to configure the backspace
> thing (or one configures the terminal directly what it should send for
> backspace).
>
> Long are the times gone, when I needed to fiddle with that ;)

I never had to fiddle. It just worked for me in Ubuntu from when I
first started with vim7.2. What ":h :fixdel" tells me to do does not
work in win32-vim inside tmux. It says if "the code for BS is alright,"
by which I understood, "if BS is working correctly," then using
":fixdel" is all I need to do, but that didn't fix it, so obviously "the
code for BS is alright" means "t_kb" needs to be something sane, which
in this case is not true (see below). So I tried this:

set t_kb=^VÎx " I pressed <C-v>, not caret and V
fixdel

But this only cause BS key in insert mode to insert "Îx" instead of
deleting the previous character; didn't impact <C-h> at all.

I also tried "set t_kD=^V<Del>" with and without the "t_kb" plus fixdel
duo above, which only caused Del key to delete the whole line instead of
the character under cursor (which works properly without setting "t_kD")

All this to say, :fixdel isn't fixing <C-h> win32-vim inside tmux.
Either that or I am missing something.

> So I would first try inside vim, what is actually printed when typing in
> insert mode <C-V><Backspace> and from there we can continue.

unix-vim inside and outside tmux (works properly):

C-v BS: ^?
C-v C-h: ^H

win32-vim outside tmux (works properly):

C-v BS: Îx
C-v C-h: ^H

win32-vim inside tmux (<C-h> doesn't work):

C-v BS: Îx
C-v C-h: <C-BS>

Above, "^x" characters are non-printable C-x characters, but "<C-x>" are
plain printable text.

--
Enan

P.S. BS and Del keys works fine in win32-vim inside tmux.

Enan Ajmain

unread,
Jul 8, 2023, 1:55:04 PM7/8/23
to Christian Brabandt, vim...@googlegroups.com
On Sat, 8 Jul 2023 23:46:50 +0600
Enan Ajmain <3nan....@gmail.com> wrote:
> On Sat, 8 Jul 2023 18:57:01 +0200
> Christian Brabandt <cbl...@256bit.org> wrote:
> [...]
>
> I never had to fiddle. It just worked for me in Ubuntu from when I
> first started with vim7.2. What ":h :fixdel" tells me to do does not
> work in win32-vim inside tmux. It says if "the code for BS is alright,"
> by which I understood, "if BS is working correctly," then using
> ":fixdel" is all I need to do, but that didn't fix it, so obviously "the
> code for BS is alright" means "t_kb" needs to be something sane, which
> in this case is not true (see below). So I tried this:
>
> set t_kb=^VÎx " I pressed <C-v>, not caret and V fixdel

I miswrote. It should be this:

set t_kb=^V<BS> " I pressed <C-v>, not caret and V fixdel

It ends up as:

set t_kb=Îx

I conflated the two.

> But this only cause BS key in insert mode to insert "Îx" instead of
> deleting the previous character; didn't impact <C-h> at all.
>
> I also tried "set t_kD=^V<Del>" with and without the "t_kb" plus fixdel
> duo above, which only caused Del key to delete the whole line instead of
> the character under cursor (which works properly without setting "t_kD")
>
> All this to say, :fixdel isn't fixing <C-h> win32-vim inside tmux.
> Either that or I am missing something.
>
> > So I would first try inside vim, what is actually printed when typing in
> > insert mode <C-V><Backspace> and from there we can continue.
>
> unix-vim inside and outside tmux (works properly):
>
> C-v BS: ^?
> C-v C-h: ^H
>
> win32-vim outside tmux (works properly):
>
> C-v BS: Îx
> C-v C-h: ^H
>
> win32-vim inside tmux (<C-h> doesn't work):
>
> C-v BS: Îx
> C-v C-h: <C-BS>
>
> Above, "^x" characters are non-printable C-x characters, but "<C-x>" are
> plain printable text.
>
> --
> Enan
>
> P.S. BS and Del keys works fine in win32-vim inside tmux.



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