8 ms·
CTRL + W usually deletes everything until the previous whitespace, so it would delete the whole '/var/log/nginx/' string in OP's example. Alt + backspace usuall
by fellerts 6mo ago
CTRL + W usually deletes everything until the previous whitespace, so it would delete the whole '/var/log/nginx/' string in OP's example. Alt + backspace usually deletes until it encounters a non-alphanumeric character.
Be careful working CTRL + W into muscle memory though, I've lost count of how many browser tabs I've closed by accident...
- fp64 6mo agoI've installed "More Better Ctrl-W" for Chromium, and mapped Ctrl-W to do nothing, and Ctrl-D to close the current tab
- arcanemachiner 6mo agoBut how am I supposed to create or edit a bookmark?
- sfink 6mo ago...which is why I recently went to about:keyboard and removed that hotkey. I love that page. That, and Ctrl-N. No more forest of blank browser windows when using a terminal emulator in a web page! (Firefox only)
- naikrovek 6mo agoCtrl+W is undoable. Ctrl+Shift+T will undo your recent tab closures in reverse order. The tabs maintain their history as well. I am very surprised at how many people in here don’t seem to know that. I learned about Ctrl+Shift+T before I learned about Ctrl+W. I was using the middle mouse button on a tab to close tabs before then.
- sfink 6mo agoI know. I used to use it fairly often when Ctrl-W still did something. It helps, but (1) it doesn't work if you closed the last tab and thus the whole window, you'd need to restore recently closed windows instead; and (2) it is still more disruptive and potentially state-losing than preventing an unwanted close in the first place. Tab history retention isn't perfect.
- oxag3n 6mo agoDepends on the shell - bash on my Ubuntu deletes entire '/var/log/nginx/', while after switching to sh it deletes only nginx
- themafia 6mo ago'man readline' contains all the useful key combinations.
- lelanthran 6mo ago> Be careful working CTRL + W into muscle memory though, I've lost count of how many browser tabs I've closed by accident... You're telling me!!! (I use vim daily, with multiple splits in a single instance.)
- naikrovek 6mo agoCTRL+SHIFT+T will resurrect your most recently closed tab, with history. Pressing it again will bring up the next most recently closed tab, with history. Etc. Or maybe you don’t use SHIFT. Can’t recall right now. My fingers know but I’m not at a computer. Anyway, browser menus can also show you recently closed tabs and bring them back.
- goplayoutside 6mo agoFirefox v147 finally added the ability to redefine keyboard shortcuts, including ^w: https://news.ycombinator.com/item?id=46952095 https://news.ycombinator.com/item?id=46952095 1. Load about:keyboard 2. Find "Close tab" and click "Clear" or "Change".
- meatmanek 6mo ago> Be careful working CTRL + W into muscle memory though, I've lost count of how many browser tabs I've closed by accident... I still maintain this is why macOS is the best OS for terminal work -- all the common keybindings for GUI tools use a different modifier key, so e.g. ⌘C and ⌘W work the same in your terminal as they do in your browser. (Lots of the readline/emacs-style editing keybindings work everywhere in macos as well -- ^A, ^E, ^K, ^Y, but not ^U for some reason)
- p_alexander 6mo ago100% agree, and I am surprised I do not see this mentioned more often. I came up on Linux and then had to use MacOS for a job and got used to the cmd / ctrl separation and now I cannot use a terminal on Linux without major pain. I've tried a few of the key rebinding options and they all feel klunky.
- gryfft 6mo agoCtrl-Shift-T usually brings that tab right back at least
- hejira 6mo agoIn my terminal it's the exact opposite – Alt-Backspace deletes to the previous space, whereas Ctrl-W deletes to the last non-alphanumeric (such as /). I'm using fish shell in an Alacritty terminal. Yeah, pressing Ctrl-W accidentially is a pain sometimes ... but Ctrl-Shift-T in Firefox is a godsend.
- Aerolfos 6mo ago> Yeah, pressing Ctrl-W accidentially is a pain sometimes ... but Ctrl-Shift-T in Firefox is a godsend. Fun fact: despite having absolutely no menu entry for it, and I believe not even a command available with Ctrl+Shift+P, Vscode supports Ctrl+Shift+T to re-open a closed tab. Discovered out of pure muscle memory.
- figmert 6mo ago> Be careful working CTRL + W into muscle memory though, I've lost count of how many browser tabs I've closed by accident... This hurts. Also, for the shell, if you do C+w, you can "paste" it back using C+y. Assuming you have not removed that configuration.
- fainpul 6mo agoSet $WORDCHARS accordingly. In your case, remove / from $WORDCHARS. https://unix.stackexchange.com/a/726014 https://unix.stackexchange.com/a/726014
- exceptione 6mo agoFor the bash people stty werase undef bind '"\C-w": backward-kill-word' source: https://superuser.com/questions/212446/binding-backward-kill-word-to-ctrlw https://superuser.com/questions/212446/binding-backward-kill...