vimtricks.wiki Concise Vim tricks, one at a time.

How do I quickly see the current filename, cursor position, and file progress without status line plugins?

Answer

Explanation

<C-g> (or :file) prints a status message at the bottom of the screen showing the current filename, modification status, cursor line and column, and percentage through the file. It works in any mode and requires no plugins or special configuration.

What it shows

"myfile.py" line 42 of 150 --28%--  col 17
  • Filename and whether it is modified ([Modified] flag)
  • Current line number and total lines
  • Percentage through the file
  • Current column number

Variants

  • <C-g> — standard info (filename, line, col, %)
  • 1<C-g> — shows the full path of the file (prefix with count 1)
  • 2<C-g> — shows the buffer number as well
  • :file — same as <C-g>, works from command mode
  • g<C-g>extended info: word count, character count, byte offset (useful for writers)

Example

Press g<C-g> in a large text file:

col 1; row 150; word 2345; char 14567; byte 14789 of 89012

This is the "word count" feature built into Vim — no plugins needed.

Tips

  • Use 1<C-g> when you need to copy the full file path (it shows in the command line message you can then recall with <C-r>: in command mode)
  • :set ruler permanently shows line/column info in the status bar so you don't need <C-g> for basic position info
  • In a session with many buffers, <C-g> is a quick sanity check for "which file am I actually editing?"
  • g<C-g> word count is handy for writing prose in Vim — no need to shell out to wc

Next

How do I run a search and replace only within a visually selected region?