[BUG] :d deletes wrong lines in folding.

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[BUG] :d deletes wrong lines in folding.

Yue Wu

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

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: [BUG] :d deletes wrong lines in folding.

Kana Natsuno

On Sat, 21 Nov 2009 09:53:33 +0900, Wu, Yue <[hidden email]> 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/


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: [BUG] :d deletes wrong lines in folding.

Yue Wu

On Sat, Nov 21, 2009 at 10:33:34AM +0900, Kana Natsuno wrote:

>
> On Sat, 21 Nov 2009 09:53:33 +0900, Wu, Yue <[hidden email]> 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.
>

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

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: [BUG] :d deletes wrong lines in folding.

Kana Natsuno

On Sat, 21 Nov 2009 12:58:58 +0900, Wu, Yue <[hidden email]> 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


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


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: [BUG] :d deletes wrong lines in folding.

Yue Wu

On Sat, Nov 21, 2009 at 01:19:07PM +0900, Kana Natsuno wrote:

>
> On Sat, 21 Nov 2009 12:58:58 +0900, Wu, Yue <[hidden email]> 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

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

List of $<VARIABLE>s

Mark Manning-5

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.  :-)


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: List of $<VARIABLE>s

Lech Lorens

On 21-Nov-2009 Mark Manning <[hidden email]> 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

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: List of $<VARIABLE>s

James Vega-3
In reply to this post by Mark Manning-5
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 <[hidden email]>

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: List of $<VARIABLE>s

Tony Mechelynck
In reply to this post by Mark Manning-5
On 21/11/09 20:15, Mark Manning 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.  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.  :-)

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.

--
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php