Count words and lines
Here’s a tip that I always forget about but is useful if you can internalize it: Press
g followed by
<ctrl-g> to get information about the current cursor position, including the current line and total number of lines plus the total number of words in the file and more.
When is this useful? A few places for me:
- Writing prose or articles and needing to aim for a certain number of words? Press
g <ctrl-g>to get the current word count.
- Writing code but have line number restrictions in your software quality tools? Press
g <ctrl-g>to see the total number of lines in the file.
g <ctrl-g>, you’ll see something like this in the Vim command line:
Col 22 of 44; Line 19 of 22; Word 70 of 74; Byte 568 of 602
Check out the demo gif below. First I’m positioned in the bottom split and I press
g <ctrl-g> to get the count of words in the Markdown file: 267 words, the essay isn’t long enough! Next, I press
<ctrl-w> k to move to the top split and press
g <ctrl-g> to get the line count on Fugitive: 6,439 lines, wow this plugin is huge!
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?