Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: Lock top line of a window

Tags:

vim

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

I have a file, say, dump of a database table. On the first line there are names of columns, other lines contain data. I want to be able to scroll contents up and down, and always see column names.

N.B. Lines can be lengthy, so I use nowrap and want column names and contents to scroll right and left simultaneously. That's why :1split doesn't suit -- unless there's a way to scroll two windows at the same time.

Thanks.

like image 959
Egor Rogov Avatar asked Nov 20 '09 21:11

Egor Rogov


1 Answers

Thanks guys! Let me summarize the actual commands that did the job 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
like image 104
Aditya Avatar answered Sep 28 '22 00:09

Aditya