0

I give some command on terminal and then type <Ctrl>+w to delete the last word.

vim apps/up_multiplier/views/create_ads_views.py

If I do <Ctrl>+w, the path is removed and only vim remains.

What should I do to remove only the last fragment of path. eg: I only want to remove create_ads_views.py in my example.

3 Answers 3

4

Try <ALT>+Backspace, that should do the trick.

1

bind '\C-f:unix-filename-rubout'

Then ctrl+f will do the work for you.

Or, use Esc and backspace to delete words delimited by slashes.

Got answer from this page:
https://unix.stackexchange.com/questions/27927/is-it-possible-to-configure-ctrl-w-delete-word

Alternate: Good question, what I can do is, ctrl+left, space, ctrl+e or end, ctrl+w (May be useful for long words). Looking for another good answer.

1

The bash command lines controls are all based on Emacs. So:

  • Esc-Backspace will delete a word as Emacs defines it (as user1305989 said above)
  • Ctrl-Y will put back what you deleted: so if you accidentally did Ctrl-W deleting the to the beginning of the line, then Ctrl-Y will put it back.
  • Esc-b will go back a word
  • Esc-f will go forward a word

I use these all the time and you get used to them.

0

You must log in to answer this question.

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