diff --git a/modules/user/base.nix b/modules/user/base.nix index c5cc9a2..7664c79 100644 --- a/modules/user/base.nix +++ b/modules/user/base.nix @@ -200,6 +200,19 @@ ${builtins.readFile ./shell/quicklinks.sh} # Interactive fzf web launcher ${builtins.readFile ./shell/jump.sh} # Directory jumper & interactive fuzzy navigation + # --- Word Deletion & Readline Keybindings --- + if [[ -n "$BASH_VERSION" ]] && [[ "$-" == *i* ]]; then + # Ctrl+W: Delete entire word under cursor (backward-word + kill-word) + bind '"\C-w": "\eb\ed"' 2>/dev/null + + # Ctrl+Delete: Forward word delete (matches Alacritty \e[3;5~) + bind '"\e[3;5~": kill-word' 2>/dev/null + + # Ctrl+Backspace / Alt+Backspace: Backward word delete (start to cursor) + bind '"\e\x7f": backward-kill-word' 2>/dev/null + bind '"\e\b": backward-kill-word' 2>/dev/null + fi + # --- Visual Entry --- # Display system information dashboard upon opening interactive shells if [[ $- == *i* ]]; then diff --git a/modules/user/config/nvim/init.lua b/modules/user/config/nvim/init.lua index 2b8a272..2287306 100644 --- a/modules/user/config/nvim/init.lua +++ b/modules/user/config/nvim/init.lua @@ -28,6 +28,30 @@ vim.keymap.set('i', '', function() end end, { expr = true, silent = true }) +-- ============================================================================= +-- Precision Word Deletion Shortcuts +-- ============================================================================= + +-- 1. Delete word backward: from word start to cursor (built-in = backward-kill-word). +-- noremap=true (default) ensures this calls Vim's native handler, NOT our custom below. +vim.keymap.set('i', '', '', { desc = 'Delete word backward (start to cursor)' }) +vim.keymap.set('i', '', '', { desc = 'Delete word backward (start to cursor)' }) +vim.keymap.set('i', '', '', { desc = 'Delete word backward (start to cursor)' }) + +-- 2. Delete word forward: from cursor to word end (preserves trailing whitespace) +vim.keymap.set('i', '', 'de', { desc = 'Delete word forward (cursor to end)' }) +vim.keymap.set('i', '', 'de', { desc = 'Delete word forward (cursor to end)' }) + +-- 3. Delete entire word under cursor (inner word), regardless of cursor position +vim.keymap.set('i', '', 'diw', { desc = 'Delete entire word under cursor' }) + +-- Normal Mode parity +vim.keymap.set('n', '', 'de', { desc = 'Delete word forward' }) +vim.keymap.set('n', '', 'de', { desc = 'Delete word forward' }) +vim.keymap.set('n', '', 'db', { desc = 'Delete word backward' }) +vim.keymap.set('n', '', 'db', { desc = 'Delete word backward' }) +vim.keymap.set('n', '', 'db', { desc = 'Delete word backward' }) + -- ============================================================================= -- Window / Tmux Seamless Navigation (Ctrl-h/j/k/l) -- ============================================================================= diff --git a/modules/user/config/tmux.conf b/modules/user/config/tmux.conf index db2a030..f06dfe4 100644 --- a/modules/user/config/tmux.conf +++ b/modules/user/config/tmux.conf @@ -9,8 +9,10 @@ set -g default-terminal "tmux-256color" -# Advertise true color / RGB support to terminal applications (Neovim, etc.) +# Advertise true color / RGB and extended keys support to terminal applications (Neovim, etc.) set -as terminal-features ',*:RGB' +set -as terminal-features 'xterm*:extkeys' +set -s extended-keys on # 1-based indexing for windows and panes (matches keyboard row 1..9) set -g base-index 1 diff --git a/modules/user/terminal.nix b/modules/user/terminal.nix index 46e797e..d1f2bab 100644 --- a/modules/user/terminal.nix +++ b/modules/user/terminal.nix @@ -3,6 +3,11 @@ { pkgs, ... }: +let + # Parse true ASCII Escape (0x1b) and DEL (0x7f) bytes so TOML serialization generates real escape sequences + esc = builtins.fromJSON "\"\\u001b\""; + del = builtins.fromJSON "\"\\u007f\""; +in { # GPU-Accelerated Terminal Emulator (Alacritty) programs.alacritty = { @@ -59,6 +64,8 @@ { key = "Minus"; mods = "Control"; action = "DecreaseFontSize"; } { key = "Key0"; mods = "Control"; action = "ResetFontSize"; } { key = "Enter"; mods = "Shift"; chars = "\n"; } + { key = "Delete"; mods = "Control"; chars = "${esc}[3;5~"; } + { key = "Back"; mods = "Control"; chars = "${esc}${del}"; } ]; }; };