Yank file name / path of current buffer in Vim

Assuming the current buffer is a file open for edit, so :e does not display E32: No file name.

I would like to yank one or all of:

  • The file name exactly as show on the status line, e.g. ~\myfile.txt
  • A full path to the file, e.g. c:\foo\bar\myfile.txt
  • Just the file name, e.g. myfile.txt

10 Answers
10

Leave a Comment