←back to thread

539 points todsacerdoti | 1 comments | | HN request time: 0.265s | source
Show context
tomsmeding ◴[] No.44358306[source]
> Escape for some reason doesn't get sent as the escape key if it shows up next to any other keys???

Welcome to ANSI escape sequences. The left arrow key, for example, is really just <Esc>[D . You can see this stuff for yourself by running `cat >/dev/null` (cat isn't actually doing anything useful here, it's just allowing you to type without the shell getting in the way and actually, you know, making an attempt to interpret the keys you press). Press backspace to figure out which bytes are represented by 1 and which by 2 characters. 2-character sequences where the first is a caret (^) can be produced by ctrl + the second character, and correspond to the second character in ASCII minus 64. Hence ^A is byte 0x01. The escape key sends ASCII ESC, number 27, and is written ^[ .

https://en.wikipedia.org/wiki/ANSI_escape_code

Software distinguishes between a bare Escape key press and an ANSI escape sequence by waiting a couple of milliseconds and seeing if more bytes arrive. The number of milliseconds is often configurable, with e.g. the 'escape-time' config key in tmux and the 'ttimeoutlen' setting in vim.

replies(1): >>44358559 #
jynelson ◴[] No.44358559[source]
this is all true but it's not related to the bug in my post. this is input being sent via `tmux send-keys`, escape-time isn't relevant.
replies(1): >>44359453 #
1. tomsmeding ◴[] No.44359453[source]
Ah, but I suspect it still is: not the tmux config option indeed, but the vim config option. After all, I think with that `tmux send-keys`, you're sending input to vim, aren't you? And vim itself does escape sequence interpretation.