1

Is it possible to find :commands entered while editing a specific file, as opposed to all commands ever typed at the : prompt? Failing that, is it possible to auto-save commands to a separate history while editing a certain file?

I've tried up-arrow and q:. I've viewed viminfo but at a first glance it seems to save all commands in one chunk.

0
  1. No, it's not possible, AFAIK. Some commands manipulate the current buffer contents, but some don't. So Vim makes a difference between, say, "commands" and "search patterns", but not between "buffer #1"-commands and "buffer #2"-commands.

  2. In principle, it's possible: trap BufEnter and BufLeave and use histadd(), histdel(), histget() and histnr() to do something useful.

Still looks pretty unnecessary job to me. Many buffers may earn from sharing the history with other buffers.

| improve this answer | |
  • Needle in a haystack problem, other times "how TF did I delete that snippet". Thanks! – Ald In Jun 14 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.