0

I'm attempting to detect whenever backspace is hit when typing in a specific scenario in Vim. I'm using getchar() to grab general characters from user input. Ideally, I'd like to detect the backspace keystroke in this manner. I was thinking of using stty somehow, but I'm not certain as of yet. Any suggestions?

4

1 回答 1

1

如果您使用的是 getchar ,则可以检查用户是否输入了退格键

let char=getchar()
if char is# "\<BS>"
    …
endif

. 这里假设 vim 配置正确(只有终端 vim,gvim 没有这个问题)。大多数情况下是这样,但有时代替修复 terminfo 或更可能的是使用set <BS>={<C-v><BS>},用户只需映射按 时产生的字符<BS>。这是没办法的。

于 2013-07-07T08:58:02.770 回答