You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Linux终端中能否区分Ctrl+Backspace与Ctrl+h?

Can Ctrl+Backspace and Ctrl+H Be Bound to Different Functions in Kitty?

Absolutely, you can distinguish and map these two key combinations to separate functions—you don’t have to accept the default behavior where both send ^H! Kitty is highly configurable, so let’s walk through how to make this work.

First, Understand the Default Behavior

Right now, Kitty maps both Ctrl+H and Ctrl+Backspace to send the ^H (ASCII backspace) character. But this is just a default setting, not a hard limitation.

Step 1: Verify Key Inputs (Optional but Useful)

First, confirm exactly what sequences Kitty is sending for each key. Run this command in your terminal:

kitty --debug-input

Press Ctrl+H and then Ctrl+Backspace—you’ll see both output something like KEY_CTRL+H (^H). This confirms they’re using the same sequence right now.

Step 2: Remap Ctrl+Backspace in Kitty’s Config

Kitty lets you override key mappings in its config file, usually located at ~/.config/kitty/kitty.conf. Open it in your editor and add a line to make Ctrl+Backspace send a unique escape sequence. A common choice for Ctrl+Backspace is \x1b[3;5~ (a standard extended terminal sequence):

# Map Ctrl+Backspace to send a unique escape sequence
map ctrl+backspace send_text all \x1b[3;5~

Save the file, then restart Kitty or run kitty @ reload-config to apply changes.

Step 3: Bind the New Sequence to Your Desired Function

Now you need to tell your target application (shell, Vim, etc.) what to do when it receives this new sequence. Here are examples for common tools:

For Bash/Zsh

Add this to your ~/.bashrc (or ~/.zshrc for Zsh) to bind Ctrl+Backspace to delete the entire previous word:

# Bash
bind '"\e[3;5~": backward-kill-word'

# Zsh
bindkey '^[[3;5~' backward-kill-word

Ctrl+H will still send ^H, which by default deletes the previous character (you can remap this too if you want).

For Vim/Neovim

Add this to your ~/.vimrc (or init.vim/init.lua for Neovim) to bind Ctrl+Backspace to delete the previous word in insert mode:

inoremap <C-BS> <C-W>

Vim should automatically recognize the \x1b[3;5~ sequence as <C-BS> if your terminal settings are correct. If not, you can explicitly map the sequence:

inoremap ^[[3;5~ <C-W>

(Note: To type the ^[ in Vim, press Ctrl+V followed by Esc.)

Why This Works

Unlike some older terminals, Kitty gives you full control over key mappings. The key is to assign a unique sequence to Ctrl+Backspace, then teach your applications to recognize that sequence as a distinct command.

内容的提问来源于stack exchange,提问作者YW P Kwon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 08:22:41