How to Tell Which Line You’re on with ‘vi’

I don’t use vi enough to be proficient with it. I use it nearly daily, but only in the most basic way possible. Whenever I have to do anything beyond ‘:q,’ ‘:wq,’ or ‘:q!’ I have to google it.

I needed to know which line I was on in vi.

:=.

That tells me which line I am on.

If I want more information, ctrl-g gives me additional information about the file and the line I’m on.

"~/tmp/drinkmorebeer" line 24 of 301 --7%-- col 1

This tells me I’m on line 24 of 301 lines and that I’m 7 percent into the file on column 1. The ctrl-g display doesn’t change as you move through the file, when I desire that information again, I must press ctrl-g again.

Share Button