i think this is a little bug of Vim

4 views
Skip to first unread message

StarWing

unread,
Nov 22, 2008, 2:09:06 PM11/22/08
to vim_use
just open your Vim, input "asdf", press <ESC> return to normal mode,
then, press'a' into insert mode and input "zxcv", then press Ctrl+W,
you will find only "zxcv" are deleted, not include "asdf", i think
it's a bug, because the doc of Vim said "See the section "word
motions", for the definition of a word.", it didn't mention "only
delete the word you type".

find it when i am modifing my script...

Tim Chase

unread,
Nov 22, 2008, 2:59:20 PM11/22/08
to vim...@googlegroups.com
> just open your Vim, input "asdf", press <ESC> return to normal mode,
> then, press'a' into insert mode and input "zxcv", then press Ctrl+W,
> you will find only "zxcv" are deleted, not include "asdf", i think
> it's a bug, because the doc of Vim said "See the section "word
> motions", for the definition of a word.", it didn't mention "only
> delete the word you type".

Not a bug, just a mental impedance mis-match between what you
expect, and your 'backspace' setting.

:help i_backspacing
:help 'backspace'

You likely want

set backspace=indent,eol,start

If you check your existing value:

set backspace?

it is likely missing at least "start" in the options which causes
your particular head-scratching. The others are handy to have in
there too.

-tim

Mark S.

unread,
Nov 22, 2008, 3:03:27 PM11/22/08
to vim...@googlegroups.com
Yes, it seems that in terminal based vim, vsn 7.2, ctrl-w only works back to the starting point of the current insert session. Subsequent ctl-w commands will not go back any further. In gvim, ctl-w goes back to the starting point of the current insert session even if that point is in the middle of a current word. A second ctl-w will take you back to the true word start. Whether its a bug in gvim that it doesn't wipe out the entire prior word is a matter of interpretation.

I have noticed that you can't ctl-w or backspace beyond the start point in (terminal) vim and found it to be annoying. You can't type 'A' to go to the end of the line, then backspace over the part that you want to get rid of like you can in gvim.

-- Mark

--- On Sat, 11/22/08, StarWing <weasl...@sina.com> wrote:

> From: StarWing <weasl...@sina.com>
> Date: Saturday, November 22, 2008, 11:09 AM
> just open your Vim, input "asdf", press
> <ESC> return to normal mode,
> then, press'a' into insert mode and input
> "zxcv", then press Ctrl+W,
> you will find only "zxcv" are deleted, not
> include "asdf", i think
> it's a bug, because the doc of Vim said "See the
> section "word
> motions", for the definition of a word.", it
> didn't mention "only
> delete the word you type".
>

StarWing

unread,
Nov 22, 2008, 3:11:22 PM11/22/08
to vim_use


On 11月23日, 上午4时03分, "Mark S." <throa...@yahoo.com> wrote:
> Yes, it seems that in terminal based vim, vsn 7.2, ctrl-w only works back to the starting point of the current insert session. Subsequent ctl-w commands will not go back any further. In gvim, ctl-w goes back to the starting point of the current insert session even if that point is in the middle of a current word. A second ctl-w will take you back to the true word start. Whether its a bug in gvim that it doesn't wipe out the entire prior word is a matter of interpretation.

yes, and i set backspace to indent,eol,start, and have no changed.

> I have noticed that you can't ctl-w or backspace beyond the start point in (terminal) vim and found it to be annoying. You can't type 'A' to go to the end of the line, then backspace over the part that you want to get rid of like you can in gvim.

no, its all right here(in windows, terminal or GUI version).


i think it does a bug. how could i submit it?

Mark S.

unread,
Nov 22, 2008, 3:13:27 PM11/22/08
to vim...@googlegroups.com
Hi Tim,

Well that clears up my annoyance. ;-)

But even with the suggested settings, when you follow the instructions in the original post you'll find that back-spacing the FIRST time takes you back to the middle of the brand new word, not to the start of the new word. To me this is a very slight annoyance, but I can see where someone who is typing furiously ahead might get out of sync due to this behavior.

-- Mark

--- On Sat, 11/22/08, Tim Chase <v...@tim.thechases.com> wrote:

> From: Tim Chase <v...@tim.thechases.com>
> Subject:
> To: vim...@googlegroups.com
> Date: Saturday, November 22, 2008, 11:59 AM
> > just open your Vim, input "asdf", press
> <ESC> return to normal mode,
> > then, press'a' into insert mode and input
> "zxcv", then press Ctrl+W,
> > you will find only "zxcv" are deleted, not
> include "asdf", i think
> > it's a bug, because the doc of Vim said "See
> the section "word
> > motions", for the definition of a word.", it
> didn't mention "only
> > delete the word you type".
>

Matt Wozniski

unread,
Nov 22, 2008, 3:37:39 PM11/22/08
to vim...@googlegroups.com

This isn't a bug, it's just not terribly well documented... When you
press <C-u> or <C-w>, vim needs to decide how much it should delete...
check out how <C-u> works with some test input. The first time you
press it, it will delete to the place where insert mode started. If
you press it again, it will do nothing if 'bs' does not contain
'start', and will delete til immediately after the end of the
automatically inserted indentation otherwise. If you press it again,
it will do nothing if 'bs' does not contain 'indent', and will delete
til the very beginning of the line otherwise. If you press it again,
it will do nothing if 'bs' does not contain 'eol', and will delete
over the beginning of the line, putting the cursor at the end of the
previous line, otherwise.

This is certainly intentional behavior, and it's very useful behavior
at that... It's just not very well documented...

~Matt

StarWing

unread,
Nov 23, 2008, 1:14:57 AM11/23/08
to vim_use
okay, i know, but why ctr-u strange?

if you input "this is a", press <ESC> and press "a" and input "apple",
then you press "Ctrl-U", you will find ctrl-U delete all things from
"this is " to "apple"! and :h 'bs' said ctrl-w AND ctrl-u will stop
once, ctrl-w does stop once, but ctrl-u didn't stop!

but i must thank you, matt, i think it's a good feature that vim can
control the behavior of backspace, and you let me know it...

StarWing

unread,
Nov 23, 2008, 1:21:37 AM11/23/08
to vim_use
btw, i just find that if i set bs to 0, ctrl-u will delete nothing, i
don't know why.

e.g. you input "this is a <ESC>aapple", then press ctrl-u, nothing
happened.
and you press ctrl-w, the word apple will be deleted.

okay, i think ctrl-w is very good, but ctrl-u is much worse.

i use Vim in windows, i don't know whether it will happened in other
platform.

Matt Wozniski

unread,
Nov 23, 2008, 12:22:18 PM11/23/08
to vim...@googlegroups.com
On Sun, Nov 23, 2008 at 1:21 AM, StarWing wrote:
>
> btw, i just find that if i set bs to 0, ctrl-u will delete nothing, i
> don't know why.
>
> e.g. you input "this is a <ESC>aapple", then press ctrl-u, nothing
> happened.
> and you press ctrl-w, the word apple will be deleted.

I can't reproduce that - vim 7.2.025 on linux. The first <C-u>
deletes "apple", then future presses do nothing. With 'bs' set to
contain 'start', the second <C-u> deletes "this is a " just fine.

> okay, i think ctrl-w is very good, but ctrl-u is much worse.
>
> i use Vim in windows, i don't know whether it will happened in other
> platform.

~Matt

StarWing

unread,
Nov 23, 2008, 5:32:08 PM11/23/08
to vim_use
i tried gvim -u NONE -U NONE, and it's all right. i think it's my
vimrc's wrong...

i have found the reason, i included the vimrc_example.vim, and there
are some lines like below:

" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break
undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>

i don't know why if the ctrl-G u break the undo-list, the behavior
became so strange...
Reply all
Reply to author
Forward
0 new messages