Thursday, May 2, 2024
62
rated 0 times [  62] [ 0]  / answers: 1 / hits: 64596  / 1 Year ago, sat, december 3, 2022, 11:37:22

Consider the following bash command line, where ^ denotes the cursor location:



svn commit -m very/long/path/to/some/file "[bug 123456] Fix the pixel issue"
^


I'd like to commit a different file with the same message. How can I delete the current word, from cursor location to the next space? Is there also a shortcut for backward deletion, form the cursor to the first space backwards?



Update: ctrl+w erases backwards, but which shortcut erases one word forward?


More From » command-line

 Answers
2

I answered similar question on unix.stackexchange.com:




Bash has readline commands that aren't bound by default. You can find
them at reference:
http://www.gnu.org/software/bash/manual/html_node/Bindable-Readline-Commands.html#Bindable-Readline-Commands



Command you are looking for is called "shell-backward-kill-word". You
have to select shortcut first. Let's use Crtl+p, since it's "previous
command" - same as up arrow.



bind '"C-p": shell-backward-kill-word'



The only difference is you have to use "shell-kill-word" command instead, since you want to delete forward.



There is also a "kill-word" command with Meta+d shortcut (try Esc+d if you don't have Meta key). It will delete only one part of path at once.


[#31850] Monday, December 5, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sator

Total Points: 258
Total Questions: 119
Total Answers: 101

Location: Sweden
Member since Fri, Apr 16, 2021
3 Years ago
;