Wikia

Vim Tips Wiki

External paste buffer

Talk0
1,613pages on
this wiki
Revision as of 10:12, April 12, 2009 by JohnBot (Talk | contribs)

Tip 623 Printable Monobook Previous Next

created 2003 · complexity basic · author zzapper · version 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

Comments

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.
<pre>

----

Around Wikia's network

Random Wiki