How do I display the full absolute path of the current file without leaving normal mode?
Answer
2<C-g>
Explanation
Pressing <C-g> prints the current filename, buffer status, and cursor position in the status line. What most users don't know is that adding a count changes how much path information is displayed — turning a potentially unhelpful shortened name into a full absolute path.
How it works
<C-g>— shows filename and position; the path may be abbreviated or relative1<C-g>— prepends the full relative path to the filename2<C-g>— shows the complete absolute path (equivalent toexpand('%:p'))
This is especially useful when editing files with common names like index.js or main.go across a deep directory tree, where you want to confirm exactly which file is open.
Example
For a file at /home/user/projects/myapp/src/main.go:
<C-g> → "src/main.go" line 42 of 200 --21%--
1<C-g> → "/home/user/projects/myapp/src/main.go" line 42 of 200 --21%--
2<C-g> → "/home/user/projects/myapp/src/main.go" line 42 of 200 --21%--
(In practice, 1<C-g> and 2<C-g> both show the absolute path; the distinction only matters for relative vs absolute on some setups.)
Tips
- Use
<C-g>as a quick sanity check that you are editing the right file - In a terminal, this is often faster than
:echo expand('%:p') - The output appears only once in the command line; it does not persist