momo zone


vim 复制内容到系统剪切版

* vim 复制内容到系统剪切版
// 寄存器 “+ “* x11
vim 有很多寄存器,可以通过 :reg 查看,其中两个是 “* 和 “+;在 linux 下的 X11下
分别表示 X11 selection 和 clipboard, 在 windows 下都表示 clipboard( 因为
windows 的窗口系统不是 X11);
在 linux 下,选择一段文件(只是选择,并不复制),这段选择的文字会自动被复制到一个
空间,这个空间就是 X11 selection,在一个可以粘贴的区域点击鼠标中键就可以复制出
selection 中内容;Vim 的visual mode 下选择的区域会自动复制到 X11 selection,
因此 vim中复制到系统剪切版的方法:直接在 visual mode下选中文字,然后在其他可以
粘贴的地方直接点击鼠标中键就可以;反过来就可以把其他应用中的内容复制到 vim。
在类 unix 系统下的 vim 中,clipboard 只有在 vim 开启了 xterm_clipboard是才可以
使用( 使用 :version 查看 vim 是否启用了 xterm_clipboard )

// 来自 vim help( :help x11-selection)
X11 provides two basic types of global store, selections and cut-buffers,
which differ in one important aspect: selections are “owned” by an
application, and disappear when that application (e.g., Vim) exits, thus
losing the data, whereas cut-buffers, are stored within the X-server itself
and remain until written over or the X-server exits (e.g., upon logging out).
The contents of selections are held by the originating application (e.g., upon
a copy), and only passed on to another application when that other application
asks for them (e.g., upon a paste).
The contents of cut-buffers are immediately written to, and are then
accessible directly from the X-server, without contacting the originating
// :help quoteplus
There are three documented X selections: PRIMARY (which is expected to
represent the current visual selection – as in Vim’s Visual mode), SECONDARY
(which is ill-defined) and CLIPBOARD (which is expected to be used for cut,
copy and paste operations).
Of these three, Vim uses PRIMARY when reading and writing the “* register
(hence when the X11 selections are available, Vim sets a default value for
|’clipboard’| of “autoselect”), and CLIPBOARD when reading and writing the “+
register. Vim does not access the SECONDARY selection.



Fill in your details below or click an icon to log in: 徽标

You are commenting using your account. Log Out /  更改 )

Google+ photo

You are commenting using your Google+ account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )


Connecting to %s

%d 博主赞过: