macbook装windows教程:在gvim中用Ctrl+X,Ctrl+C,Ctrl+V 剪切复制粘贴

来源:百度文库 编辑:偶看新闻 时间:2024/05/06 03:13:11

How to make cut/copy/paste in GVim on Ubuntu work with Ctrl+X,Ctrl+C,Ctrl+V?


protected by studiohack? Apr 27 at 1:07

This question is protected to prevent "thanks!", "me too!", or spam answers by new users. To answer it, you must have earned more than 10 reputation on this site.

4 Answers

activeoldestvotes

Add the following lines to your _vimrc or .vimrc

source $VIMRUNTIME/mswin.vimbehave mswin

But beware, visual mode is then CTRL-Q instead of CTRL-V.

For an overview what mswin.vim does see the mswin.vim sourcode.It is commented very well and if some command is unclear you can easily look it up in vim's help.

Here is a quick overview compiled from the source:

  • backspace and cursor keys wrap to previous/next line
  • CTRL-X and SHIFT-Del are Cut
  • CTRL-C and CTRL-Insert are Copy
  • CTRL-V and SHIFT-Insert are Paste
  • Use CTRL-Q to do what CTRL-V used to do
  • Use CTRL-S for saving, also in Insert mode
  • CTRL-Z is Undo; not in cmdline though
  • CTRL-Y is Redo (although not repeat); not in cmdline though
  • Alt-Space is System menu
  • CTRL-A is Select all
  • CTRL-Tab is Next window
  • CTRL-F4 is Close window

At Nippysaurus' request: I put following in my .gvimrc to show Ctrl-V besides Paste in the menu:

unmenu! Edit.Pasteaunmenu Edit.Pastennoremenu 20.360 &Edit.&PasteCtrl-V    "+gPcnoremenu    &Edit.&PasteCtrl-V+

I didn't test it thoroughly, just a quick check if it did what I expected. Works for me, hope it works for you;-)



feedback

For those of you who want to maintain the normal vim behavior but also allow for less cumbersome use of the system clipboard, see Accessing the system clipboard. If you would like gvim to use the system clipboard as it's default buffer (so any x, y, p, etc. command uses the clipboard) then add the following line to your vimrc:

set clipboard=unnamed

I personally use the buffers far more within vim than between vim and the system and as such I'd rather have a slightly more cumbersome shortcut than have my system clipboard constantly clobbered. But it's nice that the option is there for those who would prefer it.