I'm working on a text file (my notes/todo document), and I want to have the to-do list part of the document open in one Vim window (to check things off), with another to look at the rest of the document. But I want the to-do list to float over the main window in one corner, instead of taking a full-width row or full-height column away from the main document view.

I can do a :vsplit and then a :split to get three windows in an arrangement close to what I want, but I have an extra window on the lower right that I don't know what to do with:

One big window on the left, one small windoe on the upper right, and one unwanted window below that

I want to make it look more like this mock-up, where the main window and the lower-right window are merged:

One little window in the upper right, floating over the main window

I'm not particularly picky about whether long lines in the main window wrap around or are just covered by the little window. I just don't want this extra window wasting all my space.

Is this really a job for some kind of tiling window manager at the X11/Wayland level? Or can (some version of) Vim do this? Can I (ab)use the preview window for this or the Vim 8.2 popups feature if I manage to learn vimscript?

  • 2
    Popups are the only way to get something like the second image but keep in mind that they float over the contents of the parent window (sounds like that's okay with you). Here's some introductory info about popups: What are the new "popup windows" in Vim 8.2?
    – B Layer
    Dec 9 '20 at 18:27
  • 1
    It looks like you can "Running a terminal in a popup window", so maybe you can also run a normal buffer in one. Unfortunately I've discovered I don't actually have vim 8.2, so to work out if I can do that and how I will need to upgrade.
    – interfect
    Dec 9 '20 at 18:30
  • 1
    Actually, are you wanting to use it as a full-fledged buffer with all the capabilities of the main buffer? That's going to be a problem. It's not really meant for that. Quoting my answer: "The buffer has no swapfile or undo capability and is not editable by normal means but the content can be modified post-creation with popup_settext()."
    – B Layer
    Dec 9 '20 at 18:32
  • @BLayer is it possible to make a popup that's just a view on a regular buffer? If so, modification could be achieved by editing the real buffer. Of course, scrolling might be an issue, too.
    – D. Ben Knoble
    Dec 9 '20 at 18:41
  • You can create a buffer separately and pass the buffer number to popup_create(). I haven't tried it so I don't know if it's as easy as that to create something that works as a second view to a normal buffer. But possibly. As far as scrolling, scrollbars appear for popups if the text doesn't fit.
    – B Layer
    Dec 9 '20 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.