Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing Vim preview window from moving main

Tags:

vim

autocmd

Is there an autocmd for when the preview window is opened/closed?

I want to scroll the main window n lines up when it the preview window is opened, then n lines down when it is closed, to counteract the "moving text" effect that occurs natively.

Am I able to do this with the relevant autocmd (and what is it), or is there a better way for me to achieve this?

like image 592
Michael Robinson Avatar asked Jun 06 '13 10:06

Michael Robinson


1 Answers

There is no such autocmd event. But you can use WinEnter and BufDelete associated with previewwindow option to achieve something similar.

Using WinEnter you can check previewwindow; if you are on preview window, you can set a buffer variable to differ this event from subsequent events that can be generated by moving to another window and back to preview window. You can also set au BufDelete <buffer> call MyRestoreMainWindow() to call your function when preview window is closed.

like image 88
mMontu Avatar answered Nov 01 '22 04:11

mMontu