Drew LeSueur
Drew LeSueur

Reputation: 20145

How to get current file offset in Vim

I see that I can easily get the size of the screen in Vim like this:

:echo &lines . ' ' . &columns

How do I get the current offset of the file I am viewing. For example, if I am scrolled down and the line number of the first row is 100, what variable or function would give me 100?

Is there a list somewhere of all these variables/functions?

Upvotes: 1

Views: 202

Answers (1)

John Szakmeister
John Szakmeister

Reputation: 46992

You want to use the line() and col() functions with an argument of '.' (which means use the current location):

:echo line('.') . ' ' . col('.')

You can find the list of available functions here. Note: this does change with versions of Vim. Also, there is a list of variables here.

Upvotes: 3

Related Questions