3

When I open a file with gvim with the following command line option,

gvim file +5

I would like the current line (the 5th line) be scrolled to the center of gVIM's window, Is that possible?

--=--=----=--=----=--=----=--=--
|                            |
|                            |
|                            |
|                            |
|  this line was selected    |
|                            |
--=--=----=--=----=--=----=--=--

By default, it wasn't centered

4

You can use

gvim file +5 -c "normal zz"

The -c option allows you to specify an editor command to run when starting vim. zz, as others have mentioned, centers the screen on the cursor line.

0

Use an autocommand.

au VimEnter * normal zz
  • 2
    And if he does not want to do this by default? – Bernhard Oct 22 '12 at 15:40

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.