Hello.

I noticed some weird behavior when splitting lines in vim.
I have vim 1.3.154 but it did it in older versions too.

When i split some line and it contains whitespace, then instead
of the usual tab, both spaces and tab get inserted. In every other case,
indentation works fine and tabs get inserted (expandtab is off).

Let's say i am editing a .sh file and i have the line
"<tab>echo hello echo world"

If i have the cursor in "e" of the second echo and press enter,
then i get the correct result which is "<tab>echo world".
If the cursor is in the whitespace between hello and the second echo,
then i get "       <tab>echo world" that is 7 spaces and then
the tab that should normally get inserted.

if my original line is "<tab>echo hello  echo world", then
it inserts 6 spaces and then a tab. For some reason,
when i split lines vim inserts (TABSTOP-original_number_of_spaces)
spaces and then a tab instead of just a tab.

After asking in freenode #vim, other people can reproduce it too.
If someone sets autoindent then the correct behavior is seen.

So, steps to reproduce this behavior are:

1) Use the default vimrc supplied with vim or one that sets
"filetype plugin indent on", and doesn't set expandtab or
autoindent.

2) vim foo.sh (or vim foo.c) to enable indentation
It occurs both with indentexpr=GetShIndent that is used for .sh
and with cindent that is used for .c and maybe with others too.

3) :set list to see the tabs and spaces

4) Type <Tab>echo hello echo world
You should see "^Iecho hello echo world"

5) Position the cursor in the whitespace between hello
and the second echo and press enter.
You should see "       ^Iecho world" if it is reproduced,
while the expected result would be "^Iecho world"

If i omitted information that is needed, please tell me.
Thank you for your time.

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to