Using remote vim over Windows openssh inserts text into the file automatically #23829

Open
opened 2026-01-31 08:53:45 +00:00 by claunia · 0 comments
Owner

Originally created by @Fyren on GitHub (Nov 23, 2025).

Windows Terminal version

1.23.12811.0

Windows build number

10.0.19045.0

Other Software

Remote: vim-9.1.1336
Local: OpenSSH_for_Windows_10.0p2 Win32-OpenSSH-GitHub, LibreSSL 4.2.0 (also happens with 9.5p1)
Local: Linux yomi 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun 5 18:30:46 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

Steps to reproduce

  1. ssh to remote system
  2. vim doesntexist

Expected Behavior

vim would open with an empty buffer.

Actual Behavior

vim opens and immediately inputs text into the file in more than 75% of cases. Sometimes, it does work as expected. For me, it almost always inserts c0c0 or /c0c0, but rarely seems to insert slightly different text.


Related seems to be issue #1637 which is marked as fixed in 2020 (with Terminal 1.4 or so?). I found that issue through #12164 which was eventually marked as a dupe of the former.

There's https://github.com/vim/vim/issues/6365 marked as closed with the fix being in Terminal.

If I run the command from https://github.com/microsoft/terminal/issues/1637#issuecomment-687704325 I get this (after pressing enter a few more times to get hd to output):

00000000 1b 5b 32 3b 32 52 1b 5b 33 3b 33 52 0a 0a 0a 0a |.[2;2R.[3;3R....|

This doesn't match the given expected output nor the given actual output from Terminal at the time.

Additionally, from https://github.com/vim/vim/issues/6365#issuecomment-687604270, if I have vim output that additional logging info, I get this:

==== start log session Sun Nov 23 14:36:33 2025 ====
  0.025072600 : raw terminal output: "ESC[?1049hESC[22;0;0tESC[>4;2mESC[?1hESC=ESC[?2004hESC[?1004h"
  0.025164054 : raw terminal output: "ESC[1;30rESC[?12hESC[?12lESC[22;2t"
  0.025541736 : raw terminal output: "ESC[27mESC[23mESC[29mESC[mESC[HESC[2JESC[2;1H▽ESC[6n"
  0.025575884 : raw terminal output: "ESC[2;1H  ESC[3;1HESCPzzESC\ESC[0%mESC[6n"
  0.025629137 : raw terminal output: "ESC[>c"
  0.025661407 : raw terminal output: "ESC]10;?^GESC]11;?^G"
  0.026055930 : SafeState: Start triggering
  0.026663372 : setting timeout timer to 2 sec 0 nsec
  0.026957183 : looking for messages on channels
  0.026976768 : SafeState: back to waiting, triggering SafeStateAgain
  0.121551739 : raw key input: "ESC[3;3RESC[2;2RESC[3;3RESC[2;2Rc0/c0c0ESC\"
  0.121703787 : SafeState: reset: key typed
  0.122962544 : setting timeout timer to 2 sec 0 nsec
  0.123107819 : SafeState: Start triggering
  0.123143032 : looking for messages on channels
  0.123156800 : SafeState: back to waiting, triggering SafeStateAgain
  0.148485774 : raw key input: "c0/c0c0ESC\00/0000ESC\"
  0.148595563 : SafeState: reset: key typed
  0.149243984 : setting timeout timer to 2 sec 0 nsec
  0.149646816 : SafeState: Start triggering
  0.149685080 : looking for messages on channels
  0.149699609 : SafeState: back to waiting, triggering SafeStateAgain
  3.559813415 : raw key input: ":"
  3.559925446 : SafeState: reset: key typed
  3.560017843 : SafeState: Start triggering
  3.560047949 : looking for messages on channels
  3.560059937 : SafeState: back to waiting, triggering SafeStateAgain
  3.834924500 : raw key input: "q"

The ESCs are literal 0x1bs. You can see in the 12th or 18th lines the strings c0c0. (I've attached the actual file, just in case.) logfile.txt

My TERM is set to xterm-256color. Two workarounds mentioned in the vim issue, set t_u7= and set ambw=double do not appear to help. Changing my TERM to linux, for testing, does seem to help.

Originally created by @Fyren on GitHub (Nov 23, 2025). ### Windows Terminal version 1.23.12811.0 ### Windows build number 10.0.19045.0 ### Other Software Remote: vim-9.1.1336 Local: OpenSSH_for_Windows_10.0p2 Win32-OpenSSH-GitHub, LibreSSL 4.2.0 (also happens with 9.5p1) Local: Linux yomi 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun 5 18:30:46 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux ### Steps to reproduce 1. ssh to remote system 2. `vim doesntexist` ### Expected Behavior vim would open with an empty buffer. ### Actual Behavior vim opens and immediately inputs text into the file in more than 75% of cases. Sometimes, it does work as expected. For me, it almost always inserts `c0c0` or `/c0c0`, but rarely seems to insert slightly different text. --- Related seems to be issue #1637 which is marked as fixed in 2020 (with Terminal 1.4 or so?). I found that issue through #12164 which was eventually marked as a dupe of the former. There's https://github.com/vim/vim/issues/6365 marked as closed with the fix being in Terminal. If I run the command from https://github.com/microsoft/terminal/issues/1637#issuecomment-687704325 I get this (after pressing enter a few more times to get hd to output): `00000000 1b 5b 32 3b 32 52 1b 5b 33 3b 33 52 0a 0a 0a 0a |.[2;2R.[3;3R....|` This doesn't match the given expected output nor the given actual output from Terminal at the time. Additionally, from https://github.com/vim/vim/issues/6365#issuecomment-687604270, if I have vim output that additional logging info, I get this: ``` ==== start log session Sun Nov 23 14:36:33 2025 ==== 0.025072600 : raw terminal output: "ESC[?1049hESC[22;0;0tESC[>4;2mESC[?1hESC=ESC[?2004hESC[?1004h" 0.025164054 : raw terminal output: "ESC[1;30rESC[?12hESC[?12lESC[22;2t" 0.025541736 : raw terminal output: "ESC[27mESC[23mESC[29mESC[mESC[HESC[2JESC[2;1H▽ESC[6n" 0.025575884 : raw terminal output: "ESC[2;1H ESC[3;1HESCPzzESC\ESC[0%mESC[6n" 0.025629137 : raw terminal output: "ESC[>c" 0.025661407 : raw terminal output: "ESC]10;?^GESC]11;?^G" 0.026055930 : SafeState: Start triggering 0.026663372 : setting timeout timer to 2 sec 0 nsec 0.026957183 : looking for messages on channels 0.026976768 : SafeState: back to waiting, triggering SafeStateAgain 0.121551739 : raw key input: "ESC[3;3RESC[2;2RESC[3;3RESC[2;2Rc0/c0c0ESC\" 0.121703787 : SafeState: reset: key typed 0.122962544 : setting timeout timer to 2 sec 0 nsec 0.123107819 : SafeState: Start triggering 0.123143032 : looking for messages on channels 0.123156800 : SafeState: back to waiting, triggering SafeStateAgain 0.148485774 : raw key input: "c0/c0c0ESC\00/0000ESC\" 0.148595563 : SafeState: reset: key typed 0.149243984 : setting timeout timer to 2 sec 0 nsec 0.149646816 : SafeState: Start triggering 0.149685080 : looking for messages on channels 0.149699609 : SafeState: back to waiting, triggering SafeStateAgain 3.559813415 : raw key input: ":" 3.559925446 : SafeState: reset: key typed 3.560017843 : SafeState: Start triggering 3.560047949 : looking for messages on channels 3.560059937 : SafeState: back to waiting, triggering SafeStateAgain 3.834924500 : raw key input: "q" ``` The `ESC`s are literal `0x1b`s. You can see in the 12th or 18th lines the strings `c0c0`. (I've attached the actual file, just in case.) [logfile.txt](https://github.com/user-attachments/files/23696524/logfile.txt) My TERM is set to xterm-256color. Two workarounds mentioned in the vim issue, `set t_u7=` and `set ambw=double` do not appear to help. Changing my TERM to `linux`, for testing, does seem to help.
claunia added the Issue-BugResolution-External labels 2026-01-31 08:53:45 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#23829