readline – deleting word under cursor

Posted on

Problem :

E.g. Alt-d deletes word until next word boundary. There’s also a shortcut to delete until previous word boundary IIRC, but I’d like to delete word UNDER cursor (i.e. to current word left boundary and next word boundary).

Is this even available in readline?

Solution :

OK found it: you can create key bindings to “macros”:

First, choose a key combination you want to use for this “kill whole word” operation — peruse bind -sp | sort | less to see what’s in use.

Suppose Ctrl-xCtrl-w is OK, then

echo '"C-xC-w": "edeC-h"' >> ~/.inputrc

Start a new shell, and you should be good to go.

Although Ctrl-xCtrl-w is just as easy/awkward as Alt-dAlt-Backspace

Leave a Reply

Your email address will not be published. Required fields are marked *