0

I looked into the :h popup.txt and unless i missed something, did not see any mention for setting a popup window on the left or right side.

PS: I'm on Vim 8.2 (latest compiled as of now)

Any example on how to do this?

4
  • 1
    Are you sure you mean to use a pop-up window? Perhaps you just want a regular split with a scratch buffer in it? That would make more sense in the context of "left side" or "right side"... A pop-up is primarily floating, so it's really mainly useful to temporarily display some information, but as a permanent window it would quickly become quite bothersome. – filbranden Sep 13 '20 at 23:13
  • 1
    Had half of it nearly figured out, but was kinda stuck on the positioning, since i only saw mention of center and such on the popup.txt, which didn't really do the trick (not like the way your answer did!) that basically explain this i think. – Nordine Lotfi Sep 13 '20 at 23:17
  • 1
    Ah! Now I see what you're after... You'll want to look into win_screenpos('.'), winheight('.'), etc. Keeping it in sync with the current window as it scrolls might be tricky too... And if the current window gets resized. Looks like a lot of work and many details to consider. I wish you luck in implementing your feature! – filbranden Sep 13 '20 at 23:21
  • Thanks! Yeah, I didn't think much about resizing or how to make it scroll at the same time as the cursor/buffer, but the rest is nearly done. Will probably publish it if it look decent enough! – Nordine Lotfi Sep 13 '20 at 23:25
1

A popup window in Vim is a "floating" window, so it actually covers the current windows and the text in them.

You can set the line, column and adjust min/max width and height to have a popup cover the left or the right half of the screen.

For example, for a popup covering the left half of the screen:

let winid = popup_create('popup', {
    \ 'line': 1,
    \ 'col': 1,
    \ 'minwidth': &columns / 2,
    \ 'minheight': &lines - 1})

And one covering the right half:

let winid = popup_create('popup', {
    \ 'line': 1,
    \ 'col': &columns,
    \ 'minwidth': &columns / 2,
    \ 'minheight': &lines - 1,
    \ 'pos': 'topright'})

See :help popup_create-arguments for details on the arguments you can pass when creating a popup window.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.