Wednesday, February 11, 2009

vim - insert current filename

When writing comments in source code or for some other reason than I can think of right now, I like to include the current filename into current vim session.

How?
  • Enter insert mode
  • use following key sequence: ctrl-r %
POOF! You have the filename (it does include the path).

In vim % is the current filename. It is very useful when writing mappings or running commands from the : prompt.

1 comment: