sponsor Vim development Vim logo Vim Book Ad

basic Tip #623: External Paste Buffer

 tip karma   Rating 12/3, Viewed by 1106 

created:   December 17, 2003 10:31      complexity:   basic
author:   zzapper      as of Vim:   5.7

We are forever using copy and paste to copy information from application to application. Inevitably however we need to edit/reformat the buffer contents . This tip allows you to quickly open a separate VIM containing just the paste contents. You may then edit these contents as required, writing or closing VIM automatically causes the changed contents to be rewritten to the paste buffer.

The following is a CygWin script (could just as easily be a Win32 batch file)

function vxp
{
# description : Edit paste contents
gvim -c 'normal ggdG"*p' c:/aaa/xp
}

Such that I just type vxp and it opens a new Vim just containing the
current paste buffer.

To automatically cause the rewriting of the paste buffer add the following to your .vimrc

autocmd bufWritePost c:/aaa/xp normal ggVG"*y

(Thanks to Bob Chan et al from comp.editors)

 rate this tip  Life Changing Helpful Unfulfilling 

<<Deleting a buffer without changing your window layout | Insert template files into buffer ( HTML editing for example) >>

Additional Notes

[email protected], December 18, 2003 4:12
Similarly to autocmd bufWritePost you can also get Vim to automatically perform commands on entering or leaving a file(s)

BufEnter After entering a buffer.  Useful for setting
options for a file type.  Also executed when
starting to edit a buffer, after the
BufReadPost autocommands.

BufLeave Before leaving to another buffer.  Also when
leaving or closing the current window and the
new current window is not for the same buffer.
Not used for ":qa" or ":q" when exiting Vim.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
Sponsored by Web Concept Group Inc. SourceForge Logo