{"id":3740,"date":"2017-04-03T18:05:51","date_gmt":"2017-04-03T12:35:51","guid":{"rendered":"https:\/\/www.wikitechy.com\/technology\/?p=3740"},"modified":"2017-04-03T18:05:51","modified_gmt":"2017-04-03T12:35:51","slug":"make-cut-copy-paste-gvim-ubuntu","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/technology\/make-cut-copy-paste-gvim-ubuntu\/","title":{"rendered":"[ Solved -3 Answers] How to make cut\/copy\/paste in GVim on Ubuntu work with Ctrl+X,Ctrl+C,Ctrl+V"},"content":{"rendered":"<p><label class=\"label label-success\">METHOD 1:<\/label><\/p>\n<p><b>Add the following lines to your _<\/b><b>vimrc<\/b><b> or .<\/b><b>vimrc<\/b><\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">javascript code<\/span> <\/div> <pre class=\"language-javascript code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-javascript code-embed-code\">source $VIMRUNTIME\/mswin.vim<br\/>behave mswin<\/code><\/pre> <\/div>\n<ul>\n<li>But beware, visual mode is then CTRL-Q instead of CTRL-V.<\/li>\n<li>For an overview what mswin.vim does see the mswin.vim sourcode.<\/li>\n<li>It is commented very well and if some command is unclear you can easily look it up in vim&#8217;s help<\/li>\n<\/ul>\n[ad type=&#8221;banner&#8221;]\n<h4 id=\"here-is-a-quick-overview-compiled-from-the-source\"><span style=\"color: #993300;\"><b>Here is a quick overview compiled from the source:<\/b><\/span><\/h4>\n<ul>\n<li>backspace and cursor keys wrap to previous\/next line<\/li>\n<li>CTRL-X and SHIFT-Del are Cut<\/li>\n<li>CTRL-C and CTRL-Insert are Copy<\/li>\n<li>CTRL-V and SHIFT-Insert are Paste<\/li>\n<li>Use CTRL-Q to do what CTRL-V used to do<\/li>\n<li>Use CTRL-S for saving, also in Insert mode<\/li>\n<li>CTRL-Z is Undo; not in cmdline though<\/li>\n<li>CTRL-Y is Redo (although not repeat); not in cmdline though<\/li>\n<li>Alt-Space is System menu<\/li>\n<li>CTRL-A is Select all<\/li>\n<li>CTRL-Tab is Next window<\/li>\n<li>CTRL-F4 is Close window<\/li>\n<\/ul>\n<p>we put following in\u00a0 .gvimrc to show Ctrl-V besides Paste in the menu:<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">bash code<\/span> <\/div> <pre class=\"language-bash code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-bash code-embed-code\">unmenu! Edit.Paste<br\/>aunmenu Edit.Paste<br\/>nnoremenu 20.360 &amp;Edit.&amp;Paste&lt;Tab&gt;Ctrl-V    \t&quot;+gP<br\/>cnoremenu    &amp;Edit.&amp;Paste&lt;Tab&gt;Ctrl-V\t\t&lt;C-R&gt;+<\/code><\/pre> <\/div>\n<p><label class=\"label label-success\">METHOD 2<\/label><\/p>\n<ul>\n<li>If you want Cut\/Copy\/Paste to work using the &#8220;standard&#8221; hotkeys, but you don&#8217;t want to change any of the other configuration options in gvim, try do add the following to ~\/.vimrc.<\/li>\n<\/ul>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">bash code<\/span> <\/div> <pre class=\"language-bash code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-bash code-embed-code\">vmap &lt;C-c&gt; &quot;+yi<br\/>vmap &lt;C-x&gt; &quot;+c<br\/>vmap &lt;C-v&gt; c&lt;ESC&gt;&quot;+p<br\/>imap &lt;C-v&gt; &lt;C-r&gt;&lt;C-o&gt;+<\/code><\/pre> <\/div>\n[ad type=&#8221;banner&#8221;]\n<ul>\n<li>Paste only works in Visual and insert mode, so you don&#8217;t have to worry about the conflict with Ctrl-V and blockwise Visual Mode.<\/li>\n<li>This isn&#8217;t a problem, because Copy and Cut put you into insert mode, so you can immediately paste afterwards. If you try it out you&#8217;ll find that it feels completely natural.<\/li>\n<\/ul>\n<p><label class=\"label label-success\">METHOD 3:<\/label><\/p>\n<h4 id=\"gvim\"><span style=\"color: #ff6600;\"><b>gVim<\/b><\/span><\/h4>\n<ul>\n<li>If you use gVim, you can get copy-on-select behaviour when using :set guioptions+=a.<\/li>\n<li>This is enabled by default on X11 systems (copies to PRIMARY), but not on MS Windows &amp; OSX (as selecting any text would override your clipboard).<\/li>\n<\/ul>\n<h4 id=\"no-clipboard\"><span style=\"color: #99cc00;\"><b>No +clipboard<\/b><\/span><\/h4>\n<ul>\n<li>Vim requires the <b>+clipboard <\/b>feature flag for any of this to work; you can check if your Vim has this by using :echo has(&#8216;clipboard&#8217;) from within Vim (if the output is 0, it not present, if it&#8217;s 1, it is), or checking the output of vim &#8211;version.<\/li>\n<\/ul>\n<p>Most Linux distributions ship with a &#8220;minimal&#8221; Vim build by default, which doesn&#8217;t have +clipboard, but you can usually install it:<\/p>\n<ul>\n<li>Debian &amp; Ubuntu: Install <b>vim-<\/b><b>gtk<\/b> or <b>vim-gnome<\/b>.<\/li>\n<li>Fedora: install <b>vim-X11,<\/b> and run <b>vimx<\/b> instead of vim (more info).<\/li>\n<li>Arch Linux: install <b>gvim<\/b> (this will enable +clipboard for normal vim as well).<\/li>\n<\/ul>\n<p>You could also use xclip, xcopy, or xsel to copy text to the clipboard.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to make cut\/copy\/paste in GVim on Ubuntu work with Ctrl+X,Ctrl+C,Ctrl+V &#8211; It is commented very well and if some command<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1699],"tags":[7368,7381,7382,7380,7378,7370,7367,7387,7390,7388,7389,7384,7377,7372,7373,7385,7375,7371,7379,7369,7391,7383,7376,7386,7374],"class_list":["post-3740","post","type-post","status-publish","format-standard","hentry","category-linux","tag-accessing-the-system-clipboard-from-vim","tag-ansi-c","tag-c-code","tag-c-programming-language","tag-c-string","tag-copy-and-paste-text-with-vi-or-vim","tag-copy-from-gvim","tag-ctrl","tag-ctrl-alt-del","tag-ctrl-d","tag-ctrl-f","tag-ctrl-s","tag-ctrl-z","tag-cutcopypaste-and-drag-drop-functionality","tag-editing-with-gvim-supportweb","tag-functions-in-c","tag-hardware-cutcopypaste-with-arduino-leonardo","tag-how-to-copy-paste-between-files-in-vim","tag-learn-c-programming","tag-my-vivim-cheatsheet","tag-picpaste","tag-print-screen","tag-vim-cheat-sheet","tag-vim-commands","tag-vnc-doesnt-monitor-gvims-clipboard"],"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/3740","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/comments?post=3740"}],"version-history":[{"count":0,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/3740\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media?parent=3740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/categories?post=3740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/tags?post=3740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}