When in terminal I can use Ctrl+w to delete a whole word or IP (. is separator for each octet) when going leftward of prompt. However, if I try Alt+d to go rightward of prompt, terminal recognizes "." in IP for a separator and deletes only one chunk, until the . out of the whole IP.

How can I adjust that so terminal recognizes only blank spaces for separator of word or even better to have another shortcut for different separators: ., =, ,, etc?

It is very similar with maneuvering in terminal with Ctrl+Arrows (left and right) and behavior is similar based on what is set for word separator.

I read that Emacs editor sits behind what terminal uses to have those shortcuts but I could not get to twink it.

I'm trying to accomplish this in Ubuntu 10.

Here:https://askubuntu.com/questions/577433/deleting-input-forward-to-the-next-space is what I was suggested in the other forum for Ubuntu 14.

I tried this:

"So, now, if you want to combine those two keystrokes (Alt+w followed by Ctrl+w) in a new one, you will need to bind a new keystroke (in my example Alt+q) to execute the previous keystrokes as follow:

bind '"\eq": "\ew \C-w"'

Finally, to make these changes permanently, all you have to do is to add the following lines to your ~/.inputrc file (if you don't have it, then create it):

"\ew": vi-forward-bigword
"\eq": "\ew \C-w" 

but I get this as result:

When added that, Alt+w still does not work, and Ctrl + and error does not work any more. Terminal outputs ;5D and ;5C when those are used to move from word to word...

What is the difference between the two versions?

  • This is the behaviour of readline library that is used by bash to handle user input, history and so on. Read this: unix.stackexchange.com/questions/78990/…
    – orion
    Commented Feb 4, 2015 at 10:42
  • Instead of tuning inputrc, you may love the following approach: make sure EDITOR variable is defined in your shell then you can use Ctrl-X Ctrl-E to bring your current command line into editor where you can use all its power to modify the line. In case of vim, deleting till the end of WORD, that is tlll the the first space on the right can be done with dW. Modified line will be executed in your shell right after you close the editor.
    – Tagwint
    Commented Feb 4, 2015 at 10:43
  • Just put your bind command in your .bashrc and it will be set every time you open an interactive shell. That should help in case .inputrc has some problems.
    – orion
    Commented Feb 4, 2015 at 10:46
  • This may help you. Commented Feb 4, 2015 at 22:09
  • @Gilles, I will try your function... Any idea why what I have tried does not work?
    – Lacho
    Commented Feb 4, 2015 at 22:55

3 Answers 3


If you're an Emacs user, my answer probably isn't something you'll want to use, but it should still be noted on this page so here it is:

You can use vi keybindings in a bash shell very easily. Type set -o vi. Add it to your .bashrc if you like the results.

The answer to your specific question, delete forward to the next space, is accomplished with dt<Space> (delete till space) or just dE (delete to end of space-delimited Word).

Standard vi keybindings are used—the main thing to get used to (if you're a vi user already) is that you'll be in insert mode by default. So to use a Normal-mode command such as the above, type <Esc> first. Alternatively, you can hold down the Alt key while typing the first letter of your command. For instance, k is the vi command to go up one line, so <Alt>k can be used just like the up arrow—to go back one command in your history.


This can also be accomplished using find space, move forward, delete word.

"\eq": "\C-]\ \C-f\C-w"

  • When cursor is on the last word of the line, there is no space behind that word. Is there a change to fix it like "find space, but if there is no space then go to end of line"?
    – KamilCuk
    Commented Feb 18, 2021 at 11:35

If .inputrc exists, /etc/inputrc is not read anymore so you lose all the settings that you currently use (.inputrc overrides the global one). Copy the global one and just add your modification to it. Then it should work like it did before, with the addition of your new binding. Either that, or just put the bind command in your .bashrc and it'll be run every time you open an interactive shell -- basically the same effect as you have now.

If anyone knows how to "source/include" another configuration file in .inputrc, I'd very much like to hear it.

  • That would be $include, see readline's "Conditional Constructs" Commented Feb 4, 2015 at 11:44
  • @orion I deleted '.inputrc' and I don't get those weird characters any more but the command does not work. Do you know how to make bind '"\eq": "\ew \C-w"' in this version of Ubuntu and why is it different then v. 14 where it works?
    – Lacho
    Commented Feb 4, 2015 at 12:26
  • I don't know what's different in what ubuntu versions, but if you copy /etc/inputrc to .inputrc and edit it to add your binding, it should work. The problem was that by overriding /etc/inputrc, the settings that you need to make the arrows work were no longer loaded. Open /etc/inputrc to see what I mean.
    – orion
    Commented Feb 4, 2015 at 12:45
  • Hi, I have this text in .inputrc: # mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving "\e[1;5C": forward-word "\e[1;5D": backward-word "\e[5C": forward-word "\e[5D": backward-word "\e\e[C": forward-word "\e\e[D": backward-word **"\ew": vi-forward-bigword "\eq": "\ew \C-w"** $if term=rxvt "\e[8~": end-of-line "\eOc": forward-word "\eOd": backward-word $endif I added those in bold. it seems different syntactic..
    – Lacho
    Commented Feb 4, 2015 at 12:59
  • Does this work now? It should. The formatting in a comment is a bit strange, but it looks ok.
    – orion
    Commented Feb 4, 2015 at 13:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .