In Vim, how do you get the number of lines in the current file using vimscript?

I'm trying to get the count of lines in the current file using vimscript but I can't figure out how (and google is returning a bunch of crap about showing line numbers).


You can use line() function:

:echo line('$')

Pressing ctrl-g will reveal the filename, current line, the line count, your current position as a percentage, and your cursor's current column number.


You could also use

wc -l <filename>

when you select an area, then vim shows in corner how many lines you have selected if you have following in your .vimrc file: set statusline=%f\ %l,%c