[BUG] :d deletes wrong lines in folding.

4 views
Skip to first unread message

Wu, Yue

unread,
Nov 20, 2009, 7:53:33 PM11/20/09
to ml-vim_dev
How to reproduce:

1. launch vim:

> $ vim

2. Add some test text:

> Test
> foldtext1
> foldtext2
> foldtext3
> End
> hello

3. Create folding: Visual select whole lines from line 1 to line 5, use zf to
create a folding.

4. Deletes some folding lines:

> :2,4d

5. Now you will see vim has deleted line 1 to line 5.

When folding is unfolded, then :2,4d will work as expected.

vim version:

VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Sep 30 2009 16:50:58)
Included patches: 1-6, 8-35, 37-48, 50-70, 73, 75-87, 90-92, 94-100, 102-137,
139-149, 151-171, 173-190, 192-193, 195-203, 206-211, 213-215, 217-
218, 220-232, 234-239

--
Hi,
Wu, Yue

Kana Natsuno

unread,
Nov 20, 2009, 8:33:34 PM11/20/09
to vim...@googlegroups.com
On Sat, 21 Nov 2009 09:53:33 +0900, Wu, Yue <van...@gmail.com> wrote:
> 5. Now you will see vim has deleted line 1 to line 5.
>
> When folding is unfolded, then :2,4d will work as expected.

It's an intentional behavior. See :help fold-behavior - it describes:

> For Ex commands the range is adjusted to always start at the first line of a
> closed fold and end at the last line of a closed fold. Thus this command: >
> :s/foo/bar/g
> when used with the cursor on a closed fold, will replace "foo" with "bar" in
> all lines of the fold.


--
To Vim, or not to Vim.
http://whileimautomaton.net/

Wu, Yue

unread,
Nov 20, 2009, 10:58:58 PM11/20/09
to vim...@googlegroups.com

Thanks for info, but I don't understand the logical.

If I don't want this behavior, how to disable it temporaryly?

--
Hi,
Wu, Yue

Kana Natsuno

unread,
Nov 20, 2009, 11:19:07 PM11/20/09
to vim...@googlegroups.com
On Sat, 21 Nov 2009 12:58:58 +0900, Wu, Yue <van...@gmail.com> wrote:
> Thanks for info, but I don't understand the logical.

Folded lines are treated as a single line. :help 28.3

> If I don't want this behavior, how to disable it temporaryly?

Use 'foldenable' as follows:

:setlocal nofoldenable
:" Do something such as :2,4d
:setlocal foldenable

Wu, Yue

unread,
Nov 20, 2009, 11:40:31 PM11/20/09
to vim...@googlegroups.com
On Sat, Nov 21, 2009 at 01:19:07PM +0900, Kana Natsuno wrote:
>
> On Sat, 21 Nov 2009 12:58:58 +0900, Wu, Yue <van...@gmail.com> wrote:
> > Thanks for info, but I don't understand the logical.
>
> Folded lines are treated as a single line. :help 28.3
>
> > If I don't want this behavior, how to disable it temporaryly?
>
> Use 'foldenable' as follows:
>
> :setlocal nofoldenable
> :" Do something such as :2,4d
> :setlocal foldenable
>

Thanks for nice help, it works :)

--
Hi,
Wu, Yue

Mark Manning

unread,
Nov 21, 2009, 2:15:30 PM11/21/09
to vim...@googlegroups.com
I was wondering if there is a list anywhere on all of the $<VARIABLES>
which VIM has. For instance, if you do a help on $VIM (i.e.: :h $VIM)
you get information on the $VIM variable. But if you do the same for
$OS you get an error.

However, if you do

:echo $OS

Vim comes back with what operating system you are currently running
under. I am sure there are more of these variables - but I can not find
a list of them. Thus - the question.

TIA! :-)

Mark

PS: I know someone's going to say "Why do you need to do this?"
Example: How to get the current date/time. Mac and Linux do it one
way, Windows does it another. If you want to write a function that acts
according to a given OS - you need to know the OS. True - there are not
a lot of reasons to need this, but there are sometimes when you do need
it. :-)

Lech Lorens

unread,
Nov 21, 2009, 3:57:51 PM11/21/09
to vim_dev, Mark Manning
On 21-Nov-2009 Mark Manning <mar...@sim1.us> wrote:
>
> I was wondering if there is a list anywhere on all of the $<VARIABLES>
> which VIM has. For instance, if you do a help on $VIM (i.e.: :h $VIM)
> you get information on the $VIM variable. But if you do the same for
> $OS you get an error.
>
> However, if you do
>
> :echo $OS
>
> Vim comes back with what operating system you are currently running
> under.

No, it doesn't. Such variables are environment variables and Vim does
not "have" them. It gets them when it is started, uses a few of them
(namely, $VIM, $VIMRUNTIME and $VIMINIT) and makes another two available
to processes it spawns: $MYVIMRC and $MYGVIMRC.

If :echo $OS gives you back your OS name, it means you have a variable
"OS" set in your environment. In mine there is no such variable and
I get a blank line.

By the way, I believe that the vim-use mailing list would be a more
proper place for this type of questions in the future. This is vim-dev
where issues regarding Vim development and bug reports tend to be
discussed.

--
HTH,
Lech

James Vega

unread,
Nov 21, 2009, 4:02:32 PM11/21/09
to vim...@googlegroups.com
On Sat, Nov 21, 2009 at 01:15:30PM -0600, Mark Manning wrote:
> I was wondering if there is a list anywhere on all of the $<VARIABLES>
> which VIM has.

":help $<Tab>" shows the following: $HOME, $VIM, $VIMRUNTIME, $MYVIMRC,
$MYGVIMRC.

> For instance, if you do a help on $VIM (i.e.: :h $VIM)
> you get information on the $VIM variable. But if you do the same for
> $OS you get an error.
>
> However, if you do
>
> :echo $OS

That's because there's something in your environment that set $OS. Vim
doesn't do that. Aside from the above mentioned $-variables, all others are
environment variables.

> PS: I know someone's going to say "Why do you need to do this?"
> Example: How to get the current date/time.

Use the strftime() function that Vim provides. :help strftime()

> Mac and Linux do it one
> way, Windows does it another. If you want to write a function that acts
> according to a given OS - you need to know the OS.

Use has() to check for items from feature-list. E.g., has('win32') will
return 1 if you're using a Vim built for 32-bit versions of Windows.
has('mac') will return 1 if you're running the mac version of Vim.

See ":help has()" and ":help feature-list".

--
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega <jame...@jamessan.com>

signature.asc

Tony Mechelynck

unread,
Dec 6, 2009, 12:26:56 PM12/6/09
to vim...@googlegroups.com, Mark Manning
Try the following:

:new
:0r !set

(with a space before the exclamation mark). In some shells, including
(but not necessarily limited to) command.com, cmd.exe and bash, this
will answer your question. It should show you the environment Vim passes
to the processes it spawns, most of which it will have inherited from
whatever shell or window-manager launched it.

Another possibility (to get the names but not the values) is

:echo $^D

where ^D means "hit Ctrl-D".


Best regards,
Tony.
--
A baby is an alimentary canal with a loud voice at one end and no
responsibility at the other.
Reply all
Reply to author
Forward
0 new messages