Raghav
Raghav

Reputation: 796

Moving to middle of huge file in Vim or gVim

Is there a Vim command to move to the middle of a huge file without calculating (total lines/2) and using j? Something like zz, zt, or zb, which moves only around the current screen?

Upvotes: 22

Views: 10570

Answers (1)

Thomas Dickey
Thomas Dickey

Reputation: 54523

You can use one of the features that vim borrowed from elvis: it accepts a percentage of the file directly. For example, typing

50%

jumps to the middle of the file.

In vim, if you enter

:h up-down-motions

that leads to the section describing the feature:

{count}%    Go to {count} percentage in the file, on the first
            non-blank in the line |linewise|.  To compute the new
            line number this formula is used:
                ({count} * number-of-lines + 99) / 100
            See also 'startofline' option.  {not in Vi}

Upvotes: 48

Related Questions