1

I am trying to save file with a generated name from vim command mode. I am using the command:

:w !tee"/tmp/vim/$(date +'%s').tmp"

But it throws me an error that filename cannot be empty. Am I missing something here?

1 Answer 1

0

Use:

:w !tee "/tmp/`date +'\%s'`.tmp"

Explanations:

  • '%' is expanded by vim into the filename, this is why it complains about it being empty. You need to escape it.
  • The bash style $(...) commands seem not to work in vim system calls.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .