3

I have the following in my vimrc:

set tabstop=8
set shiftwidth=4
set softtabstop=4
set expandtab

set backspace=indent,eol,start

set autoindent

This does what I want: insert spaces only, never tab characters; pressing tab inserts 4 spaces; automatic indents are 4 spacces.

If I'm indented n levels and hit backspace in insert mode I go back 1 indent level (1 sts) to level n-1.

How can I configure the backspace key to take me back a single space instead?

Lewis
  • 31
  • 2

3 Answers3

2

This seems to work:

imap <BS> <Left><Del>

Update: That makes backspace behave oddly at the left margin. This fixes that problem:

set whichwrap+=[
garyjohn
  • 36,494
1

Removing "set softtabstop=4" will also give you the backspace behavior you want, although it may break other behaviors you're used to.

0

You could use

set tabstop=4 shiftwidth=4 expandtab

and delete

set softtabstop=4

and forget about tabs.

In my experience, tabs used to structure text sooner or later become a nuisance.

Josephine
  • 109
  • 1