Vim: lock the top row of the window

Is it possible in Vim to lock the top line of the window so that the first line in the buffer is always visible on top of the window?

I have a file, say, a dump of a database table. The first row has column names, the other rows contain data. I want to be able to scroll contents up and down and always see column names.

NB Rows can be long, so I use nowrap and want the column names and contents to scroll right and left at the same time. Therefore :1split not suitable - if it is not possible to scroll two windows at the same time.

Thanks.

+4
source share
3 answers

You can scroll two windows at the same time, so I think you can do what you want by breaking your window and blocking the scroll behavior. See : scrollbind and this tip for more details. Please note that you need to lock each window so that they move synchronously.

+2
source

Divide your window, reduce the height of the top window, set the first top line of the first and return to the working window.

 :split :resize 1 gg Ctrl-w w 
+1
source

Thanks guys! Let me summarize the actual commands that did this work for me:

 :1spl # create an extra window with only 1 line :set scrollbind # synchronize upper window ctr+W , arrowDown # switch to other window :set scrollbind # synchronize lower window :set sbo=hor # synchronize horizontally 
0
source

All Articles