Aliar
Aliar

Reputation: 79

why is `ctrl -h` not work in insert mode?(version gvim 8.1.1)

In "Practical Vim" (second edition), the writer says <c-h> can delete back a character. I've tried in git bash, and it worked. However, it doesn't work in gvim in win10 as expected.

When I enter something in insert mode, I can use <c-h>, <c-w> and <c-u> before I leave insert mode. When I switch to insert mode without entering anything, <c-h>, <c-w> and <c-u> don't work.

Note that <c-h> is not mapped (:map <c-h> prints No mapping found).

Upvotes: 2

Views: 1230

Answers (1)

Ralf
Ralf

Reputation: 1813

Vim, by default, does only allow to delete characters that you typed since you entered insert mode. It does not allow to delete chars before the point where you started inserting. This behavior is inherited from the original Vi.

To change that, Vim has the option 'backspace'. It configures how <Backspace>, <Del>, <c-w> and <c-u> work. Add the following to your _vimrc and Vim will behave as you expect:

set backspace=indent,eol,start

Then you can backspace over autoindent, start of insert and end-of-lines.

See :help 'backspace'.

Upvotes: 1

Related Questions