Am 13.12.2017 um 18:57 schrieb Gary Johnson:
I've had a bug in one of my plugins that I finally traced to what
appears to be a bug in Vim (8.0.1257): a substitution on one line
of a closed fold affects all lines in that fold.
Here's an example. Create a file, fold_test, as shown.
---------------------------- fold_test ----------------------------
{{{1
line 2
line 3
line 4
line 5
}}}1
line 7
line 8
line 9
line 10
vim: fdm=marker
-------------------------------------------------------------------
Then edit that file as follows.
$ vim -N -u NONE -i NONE fold_test
Note that lines 1 through 6 are folded. Do the following.
:3s/line/dog/
zR
Note that "line" has been changed to "dog" in lines 2 through 5.
Then do the following.
:3s/dog/cat/
Note that "dog" has been changed to "cat" in only line 3, as
expected. The result looks like this.
{{{1
dog 2
cat 3
dog 4
dog 5
}}}1
line 7
line 8
line 9
line 10
vim: fdm=marker
That an explicit substitution on one line affects all lines in the
closed fold looks like a bug to me. It is certainly unexpected.
Regards,
Gary
Works as documented:
:h fold-behavior
For Ex commands that work on buffer lines 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.
Also try simpler commands like
:#
:.#
on a closed fold.
--
Andy
--
--
You received this message from the "vim_dev" 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
---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.