Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Consider the following bash prompt, where ^ denotes the prompt 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?

share|improve this question
Ctrl u is an option for erasing from cursor location to beginning... – nutty about natty Apr 8 '13 at 15:23
Try alt + d, that might be useful, when emacs editing mode is set. – user76204 Apr 8 '13 at 16:20
@Mik how do you enable emacs mode? – Adam Matan Apr 9 '13 at 9:00
@AdamMatan set -o emacs enables it, but it is usually the default; if not, you can put that line in .bashrc or .bash_aliases, then source the file or reload the terminal. However, then the shortcuts you may be used to in vi mode won't be available, although ones such as ctrl+c will because they are not Bash shortcuts. – user76204 Apr 9 '13 at 9:25
up vote 31 down vote accepted

I answered similar question here:

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.

share|improve this answer
Alt-d works for me – ricab Jan 20 '15 at 14:24
Generally, in the world of keyboards where Meta doesn't exist, Alt = Meta. – Nate C-K Mar 20 '15 at 3:49
I the world where you have many different keyboards, a convenient and fairly useful fact is that Esc as a prefix also acts as Meta. – tripleee Nov 30 '15 at 18:03

Tested both the esc+d and alt/opt+d on OSX Mavericks and they work there as well.

share|improve this answer
Option + d gives me ∂ on OSX – Ivan Balashov Apr 16 at 7:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.