On Sun, 24 Oct 2010 01:28:15 +0900, Bram Moolenaar <[email protected]> wrote:
> Suppose someone writes a complicated Vim script, that includes a mapping
> that moves the cursor around, but does not want folds to change.  When
> "map" is included in 'foldopen' this would be very difficult.
> It would require the mapping to temporarily remove "map" from
> 'foldopen', do its thing, then restore 'foldopen to the previous value.

Ah, that's right.  I didn't think about that case.  And now I realized
why the current 'foldopen' doesn't work for key mapppings.  When user
defines a key mapping like the following:

    noremap <C-n>  }}}

The user probably expects <C-n> to work as a new motion, not moving
the cursor 3 times.  So if <C-n> should open a fold automatically, it
should behave "}}}zv", not "}zv}zv}zv".  So the patch (:set
foldopen+=map) doesn't make a sense, does it?

At least, :help 'foldopen' should have a description like the above
for clearness.


> I don't like adding a new item unless it's a clear improvement, and in
> this case it's debatable.
>
> The problem "my mapping doesn't open folds" is a lot easier to recognize
> and fix.

In many cases, it's easy to add zv for each key mapping.  But there is
a case that it's hard to add zv.  For example:

    noremap /  :<C-u>set noincsearch<Return>/
    noremap g/  :<C-u>set incsearch<Return>/

And it's a painful work to add zv and it's easy to forget adding zv
for each key mapping when user has many key mappings in vimrc.

Anyway, I'll reconsider about another way to improve 'foldopen'
behavior.  Thank you for the advice.

-- 
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

Raspunde prin e-mail lui