Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using alt+backspace key in vim command line to delete by words

Tags:

vim

Is there a way to use the alt+backspace in vim command line? It gets unruly when having to backspace /very/long/file/path individually instead of using alt+backspace to delete by words.

like image 343
sent-hil Avatar asked May 18 '11 02:05

sent-hil


4 Answers

try using instead <c-w> (that is ctrl+w) to erase words or <c-u> (ctrl+u) to delete lines.

like image 59
skeept Avatar answered Nov 14 '22 08:11

skeept


http://vim.wikia.com/wiki/Map_Ctrl-Backspace_to_delete_previous_word

:imap <C-BS> <C-W>

sets ctrl backspace, i have to look at how to do alt

like image 44
loosecannon Avatar answered Nov 14 '22 09:11

loosecannon


If you are at the end of the path you can hit B followed by a dW (case matters). This will jump you to the beginning of the word (ignoring the slashes) and subsequently delete the word (again ignoring the slashes).

Hope this helps.

like image 1
wilbbe01 Avatar answered Nov 14 '22 08:11

wilbbe01


Vim is unable to receive alt input. skeept's answer seems to be the best alternative.

See this answer:

The Alt/Meta key is problematic in Vim and most terminals, see this answer of mine for an overview of the situation (the situation is the same for Meta and Alt).

In short, Vim doesn't receive Alt at all: hitting Alt+Backspace is exactly the same as hitting Backspace.

Anyway, it will be better for you in the long term to learn and get accustomed to Vim's default key-mappings.

like image 1
kas Avatar answered Nov 14 '22 09:11

kas