vim autoindent + :set bs=0 + ctrl+u is broken
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
vim (Ubuntu) |
Fix Released
|
Medium
|
Scott James Remnant (Canonical) |
Bug Description
Vim takes a backspace= option to determine how far it should diverge from the class Vi backspace behaviour (which states that backspace will not erase things not entered in the current insertion).
It has 3 options:
indent - backspace will erase indenting created by autoindent
eol - backspace will erase across newlines
start - backspace will erase past the start of insertion
You can use 0 to disable all of the options. The setting is also supposed to affect CTRL+W and CTRL+U.
There is a corner case there this doesn't work.
vim somefile.c
:set bs=0
int
main (void)
{
(vim indents this line)
on the indented line if you press backspace or ^W or ^U nothing happens because the backspace option says that you are not able to erase autoindented spaces. Good.
Type some text in here. Erase it using backspace or ^W. Notice that the erasing stops at the start of your typing. In all cases so far Vim has prevented you from erasing the indent characters.
Now: enter some text and type ^U to erase it. The indent character are now gone. The one case where it would be most useful to prevent you from erasing the autoindent characters (ie: ^u to restart typing the current line) is the exact case where you get shot in the foot.
The problem is in edit.c in the function ins_bs() at this line:
if (mode == BACKSPACE_LINE && curbuf->b_p_ai
as it turns out, the default Ubuntu vim config has 'autoindent' _disabled_ (ie: curbuf->p_p_ai is 0). For some reason, the autoindenting still happens though.
So basically, with the Ubuntu config:
- autoindent is actually enabled (in that it occurs)
- but the autoindent option proper is not actually set (so the backspace code breaks)