Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a file opened with vim, how do I keep the top 10 header lines at the top all the time while I scroll down the page?

share|improve this question


esc : 10 sp

ctrl-w to switch between.

They are referred to as viewports in vi parlance.

share|improve this answer
Wilshire wanted to add: "shift-ZZ to go back to normal viewing" – Chris S Jun 16 '11 at 1:38
Note that the split comand (sp is short for split) is specific to vim. These days it's a pretty safe bet that you if you're on a Linux system you are running vim, but it's worth noting that if you find yourself on a system with vanilla vi (FreeBSD, Solaris) that this won't work. – larsks Jun 16 '11 at 2:39

The keystrokes ctrl-w s will split the screen horizontally, and ctrl-w ctrl-w will switch your focus back and forth. You can widen the current viewport with ctrl-w +, or make is smaller with (any guess?) ctrl-w -.

You can do vertical splits with ctrl-w v, and you can split a split to make fairly complex sets of viweports inside the vim screen.

Using :q will close your current viewport.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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