created January 2, 2002 · complexity basic · author Robert Ames · version 6.0
In insert mode, pressing Ctrl-W deletes the previous word (:help word). If a non-Vim method is wanted, the following mapping can be used in gvim to allow Ctrl-Backspace to be used instead of Ctrl-W:
" Map Ctrl-Backspace to delete the previous word in insert mode. imap <C-BS> <C-W>
If the mapping is always wanted, place the above in your vimrc.
By default, Ctrl-W only deletes previous words in the text entered after last starting insert mode, and stops deleting text at the beginning of a line. The 'backspace' option can be set to control what is wanted. For example, the following causes Ctrl-W to always delete the previous word:
Mapping Ctrl-Backspace does not work in terminal Vim. Following is a workaround.
noremap! <C-BS> <C-w> noremap! <C-h> <C-w>
There are some issues with <C-w>. For example it considers the insert mode's point of entry as a word boundary. Also, in readline <C-w> usually means to kill the previous WORD. There is a way to make it more readline-ish:
inoremap <C-w> <C-\><C-o>dB inoremap <C-BS> <C-\><C-o>db