Automatic folding breaks completion menu?

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

Automatic folding breaks completion menu?

Peter Odding-3
Hi list,

I've been writing LaTeX for the last few hours and I have Vim configured
to use fold markers and automatically open/close folds as I move the
cursor. I mark each \section and \subsection in my LaTeX documents with
a trailing comment and fold marker, e.g.:

        \subsection{Mediatheek opdracht} % {{{2

So that when I move the cursor outside of all folded text I get a nice
outline of the document which is really useful because LaTeX documents
tend to grow quite large. I typed the following line:

        \subs<C-x><C-l>

Expecting to get a completion menu listing all of the existing
subsections. What happens however is that Vim draws the menu and
completes the first matching line, sees the fold marker that was just
introduced in the buffer by completing the first match and folds the
text above the new fold marker, which causes the completion menu to close.

In effect this makes it impossible to use the completion menu to
complete whole lines containing fold markers when you also have Vim
configured to automatically open/close folds.

A seemingly simple workaround would be to disable all automatic text
folding while the completion menu is visible. Is this easy to implement
in Vim and do others agree this is a more sensible thing to do?

Thanks for your time,

  - Peter Odding

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Automatic folding breaks completion menu?

Peter Odding-3
> A seemingly simple workaround would be to disable all automatic text
> folding while the completion menu is visible. Is this easy to implement
> in Vim and do others agree this is a more sensible thing to do?

To clarify: By disable I meant "temporarily ignore changes to folding",
not "unfold all text and then start the completion" because that would
get very annoying very quickly :-)

  - Peter Odding

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Automatic folding breaks completion menu?

Benjamin Fritz


On Jun 8, 8:59 pm, Peter Odding <[hidden email]> wrote:
> > A seemingly simple workaround would be to disable all automatic text
> > folding while the completion menu is visible. Is this easy to implement
> > in Vim and do others agree this is a more sensible thing to do?
>
> To clarify: By disable I meant "temporarily ignore changes to folding",
> not "unfold all text and then start the completion" because that would
> get very annoying very quickly :-)
>

How about temporily ignoring changes to folding until you leave insert
mode?

      " Don't screw up folds when inserting text that might affect
them, until
      " leaving insert mode. Foldmethod is local to the window.
Protect against
      " screwing up folding when switching between windows.
      autocmd InsertEnter * if !exists('w:last_fdm') | let
w:last_fdm=&foldmethod | setlocal foldmethod=manual | endif
      autocmd InsertLeave,WinLeave * if exists('w:last_fdm') | let
&l:foldmethod=w:last_fdm | unlet w:last_fdm | endif

This doesn't work for some patch levels in Vim 7.2...I don't recall
the exact patch number that makes it work again.

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