SeedmanJ
SeedmanJ

Reputation: 444

How to don't save code in vim

is it possible to add text to a file, and make vim don't save it ?

To clarify the thing, I'm creating a vim-plugin that would add perfs informations above functions, but I don't want these to be saved.

I thought to "fold" these informations, but it's also saved; I searched on Google but it seems nobody ever tried to don't save a part of his code (as it's a bit nonsense :D).

So if you ever heard of such thing, I would grately appreciate it ! Thanks in advance.

Upvotes: 2

Views: 247

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172698

Remember that Vim is a text editor; your feature is closely related to IDEs. Therefore, I can think of only kludges and hacks:

  • The only built-in features that make text appear different that what it is are conceal, which can only hide characters or replace them with a single char (not useful for you), and folding, where you could use a custom 'foldtext' to add your information (but it would interfere with the regular filetype's folding).
  • In GVIM, you could use a mouse tooltip through the 'balloonexpr'.
  • You could actually modify the text on BufWritePre / BufWritePost events, but if the information is only supplementary and should never be persisted, that's unnatural (jumps, searches, etc. would also be affected), and it could break, leaving the text behind.
  • Many plugins create a separate scratch buffer with :new and :setlocal buftype=nofile; see :help special-buffers. In that, you can do whatever you want, but it's separate from the original file.

Upvotes: 7

Related Questions