I try to make effective use of vim's copy buffers by assigning regularly used commands to each one; but there never seems to be enough of them. When editing an html doc for example I bind </li><br>\n\t<li> to the "l copy buffer, but when editing a bash script use the "l buffer for a bash specific command. So between sessions I continuously have to copy one command out for the other and re-save it in the buffer depending on what kind of file I am editing, never mind if I am editing one of each simultaneously, which is often enough to consider it a common occurrence.
Is there a way I can create profiles for different copy buffers and load them depending on what kind of file I am editing?
The file ~/.viminfo contains the copy buffers currently stored. I guess you could create a copy of it, say ~/.viminfo_html with all your html shortcuts, and another named ~/.viminfo_bash with all your scripting shortcuts and before you open vim you can set either one to be ~/.viminfo.
It looks like /.viminfo gets loaded into memory by vim when it starts up, and so if you wanted to edit an html and a .sh file simultaneously making use of your two ~/.viminfo files you could (I tried it and it works, even if you add new data to some previously assigned copy buffers, the data in other buffers of the previous ~/.viminfo file loaded at vim startup but since changed are still available, but I did not test much or for long enough to see whether or not copy buffer data unchanged remains stable for the duration of a vim session) simply swap out the current ~/.viminfo file for the alternate and open the document in a new vim session in a separate terminal session.
If the .viminfo file you need from one session to another is totally sporatic and unpredictable, then you could whip up a little script to prompt you to select which .viminfo file to rename before starting vim.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With