Multiple copy buffer profiles for vim?
I'm trying to make good use of vim's copy buffers by assigning regularly used commands to each one; but they are never enough. For example, when editing an html document, I bind </li><br>\n\t<li>
to the copy buffer "l
, but when editing a bash script, use a buffer "l
for the special bash command. So between sessions, I have to constantly copy one command for another and re-store it in the buffer depending on which file I am editing, it doesn't matter if I edit one of them at the same time, which is often enough to consider it a common occurrence.
Is there a way to create profiles for different copy buffers and load them depending on which file I am editing?
source to share
The file ~/.viminfo
stores copy buffers. I think you could create a copy of it, say ~/.viminfo_html
with all your html shortcuts, and another named ~/.viminfo_bash
with all your script shortcuts and before opening vim you can set one of them as ~/.viminfo
.
It looks like it's /.viminfo
loaded into vim's memory on startup, so if you want to edit the html and .sh file at the same time using your two files ~/.viminfo
, you could (I tried) and it works even if you add new data to some previously assigned copy buffers , the data in other buffers of the previous file ~/.viminfo
loaded when vim was started, but since the changed is still available, but I haven't tested much or long enough to check if the copy buffer data has changed remains unchanged throughout the vim session) just replace the current one file ~/.viminfo
for the alternate and open the document in a new vim session in a separate terminal session.
If the file .viminfo
you want from one session to the next is completely casual and unpredictable, you can wrinkle your script a bit to prompt you to choose which file to .viminfo
rename before starting vim.
source to share
These are called "registers", not "copy buffers".
You really should be using the right snip extension plugin like the original Snipmate , forked Snipmate , fancy UltiSnips, or the venerable XPtemplate .
I will explain two less "advanced" methods there .
source to share