ubuntu vim复制内容至系统剪切板
2018-03-03 20:17
441 查看
在VIM中编辑的程序有时需要复制到网页、gedit,或者这window系统中(如果ubuntu是虚拟机),那么用原先的复制y(yank)和p(paste)就不行了。
一、vim寄存器
为何用y,p可以在vim之间复制内容,却不能将内容复制到其他软件中呢?因为y是将内容复制到vim的一个寄存器,而这个寄存器并不是系统的剪切板。vim中也有系统剪切板的寄存器,需要用其他命令进行操作。:help registers可以在vim使用上述命令,查看vim支持的所有寄存器.
There are ten types of registers:
1. The unnamed register ""
2. 10 numbered registers "0 to "9
3. The small delete register "-
4. 26 named registers "a to "z or "A to "Z
5. three read-only registers ":, "., "%
6. alternate buffer register "#
7. the expression register "=
8. The selection and drop registers "*, "+ and "~
9. The black hole register "_
10. Last search pattern register "/
8. Selection and drop registers "*, "+ and "~
Use these registers for storing and retrieving the selected text for the GUI.
See |quotestar| and |quoteplus|. When the clipboard is not available or not
working, the unnamed register is used instead. For Unix systems the clipboard
is only available when the |+xterm_clipboard| feature is present. {not in Vi}
第8个寄存器就对应系统的剪切板。只有当vim的xterm_clipboard存在时,方可以使用系统的剪切板。那么如何看vim的xterm_clipboard是否存在呢?$vim --version或者是$vim --version | grep clipboard查看xterm_clipboard前是+还是-,+表示可用,-表示不可用。
如果xterm_clipboard不可用,需要按照vim的插件
$sudo apt-get install vim vim-scripts vim-gtk vim-gnome
安装之后,可以再次查看,发现xterm_clipboard从-变成了+。
二、操作方法
可以shift+v,ctrl+v进行visual模式进行选择。
复制:"+y
粘贴:"+gp
但是显然复制和粘贴的命令都比较复杂,可以将其绑定成其他更方便的快捷键。进行.vimrc文件添加下列命令let mapleader = ","
"set shortcut for copy to clipboard of system
nmap <leader>c "+y
nmap <leader>v "+gp就将"+y 绑定为 ,c,将"+p 绑定为 ,v
主要参考:
点击打开链接
点击打开链接
一、vim寄存器
为何用y,p可以在vim之间复制内容,却不能将内容复制到其他软件中呢?因为y是将内容复制到vim的一个寄存器,而这个寄存器并不是系统的剪切板。vim中也有系统剪切板的寄存器,需要用其他命令进行操作。:help registers可以在vim使用上述命令,查看vim支持的所有寄存器.
There are ten types of registers:
1. The unnamed register ""
2. 10 numbered registers "0 to "9
3. The small delete register "-
4. 26 named registers "a to "z or "A to "Z
5. three read-only registers ":, "., "%
6. alternate buffer register "#
7. the expression register "=
8. The selection and drop registers "*, "+ and "~
9. The black hole register "_
10. Last search pattern register "/
8. Selection and drop registers "*, "+ and "~
Use these registers for storing and retrieving the selected text for the GUI.
See |quotestar| and |quoteplus|. When the clipboard is not available or not
working, the unnamed register is used instead. For Unix systems the clipboard
is only available when the |+xterm_clipboard| feature is present. {not in Vi}
第8个寄存器就对应系统的剪切板。只有当vim的xterm_clipboard存在时,方可以使用系统的剪切板。那么如何看vim的xterm_clipboard是否存在呢?$vim --version或者是$vim --version | grep clipboard查看xterm_clipboard前是+还是-,+表示可用,-表示不可用。
如果xterm_clipboard不可用,需要按照vim的插件
$sudo apt-get install vim vim-scripts vim-gtk vim-gnome
安装之后,可以再次查看,发现xterm_clipboard从-变成了+。
二、操作方法
可以shift+v,ctrl+v进行visual模式进行选择。
复制:"+y
粘贴:"+gp
但是显然复制和粘贴的命令都比较复杂,可以将其绑定成其他更方便的快捷键。进行.vimrc文件添加下列命令let mapleader = ","
"set shortcut for copy to clipboard of system
nmap <leader>c "+y
nmap <leader>v "+gp就将"+y 绑定为 ,c,将"+p 绑定为 ,v
主要参考:
点击打开链接
点击打开链接
相关文章推荐
- vnc viewer中开启剪切板复制内容到ubuntu系统中
- vim 复制到系统剪切板 VS 系统剪切板粘贴到vim
- Vim复制文件全部内容到系统剪贴板
- vim "+y"复制到系统剪切板 无效
- VIM复制到系统剪切板
- Vim-复制选中内容至系统剪贴板,光标移动到指定行的行首和行尾
- ubuntu下vim与系统剪切板互相拷贝
- vim中把剪切板中的内容复制到正在编辑的文件中的快捷键
- Ubuntu Vim复制内容到其他应用(Ctrl C + Ctrl V)
- ubuntu下vim中内容复制到浏览器
- VIM复制到系统剪切板
- 在vim粘贴系统剪切板里的内容
- vim复制粘帖系统剪切板
- Vim无法将内容复制到系统剪贴板
- VIM复制到系统剪切板
- vim在系统剪切板的复制与粘贴
- vim编辑器 复制全部内容到剪切板
- 使用vim-gui-common实现从vim窗口复制内容到系统剪贴板
- vim 系统剪切板及 ubuntu 无法使用 vim 系统剪贴板(或 :reg 无+号寄存器)
- Ubuntu Vim 复制到系统粘贴板