How to copy paste contents in the vi editor












140















I tried using Ctrl + V for pasting contents in a vi editor document, but Ctrl + V is not interpreted as a paste.










share|improve this question




















  • 16





    Just a note, the main reason to use Vi is because Vim isn't installed. If you have Vim installed, it's probably worth using that instead. There isn't really an advantage to Vi besides that it is already present on every Unix install. The best way to learn Vim in my opinion is to open your terminal emulator (not from within Vim) and type vimtutor It will get you up to speed to where it's usable to you in about 45 minutes.

    – Ben Mordecai
    Feb 16 '13 at 18:58






  • 1





    +1 @BenMordecai - I was already familiar with vi (from old), including its convenient sub-shell capability, but needed that refresh. Great little bit of tutoring. Went through it like a breeze. Thanks.

    – Cbhihe
    Oct 2 '14 at 16:35


















140















I tried using Ctrl + V for pasting contents in a vi editor document, but Ctrl + V is not interpreted as a paste.










share|improve this question




















  • 16





    Just a note, the main reason to use Vi is because Vim isn't installed. If you have Vim installed, it's probably worth using that instead. There isn't really an advantage to Vi besides that it is already present on every Unix install. The best way to learn Vim in my opinion is to open your terminal emulator (not from within Vim) and type vimtutor It will get you up to speed to where it's usable to you in about 45 minutes.

    – Ben Mordecai
    Feb 16 '13 at 18:58






  • 1





    +1 @BenMordecai - I was already familiar with vi (from old), including its convenient sub-shell capability, but needed that refresh. Great little bit of tutoring. Went through it like a breeze. Thanks.

    – Cbhihe
    Oct 2 '14 at 16:35
















140












140








140


48






I tried using Ctrl + V for pasting contents in a vi editor document, but Ctrl + V is not interpreted as a paste.










share|improve this question
















I tried using Ctrl + V for pasting contents in a vi editor document, but Ctrl + V is not interpreted as a paste.







editor vi






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 19 '18 at 21:28









Peter Mortensen

1,03421016




1,03421016










asked Feb 16 '13 at 8:13









RpjRpj

91451220




91451220








  • 16





    Just a note, the main reason to use Vi is because Vim isn't installed. If you have Vim installed, it's probably worth using that instead. There isn't really an advantage to Vi besides that it is already present on every Unix install. The best way to learn Vim in my opinion is to open your terminal emulator (not from within Vim) and type vimtutor It will get you up to speed to where it's usable to you in about 45 minutes.

    – Ben Mordecai
    Feb 16 '13 at 18:58






  • 1





    +1 @BenMordecai - I was already familiar with vi (from old), including its convenient sub-shell capability, but needed that refresh. Great little bit of tutoring. Went through it like a breeze. Thanks.

    – Cbhihe
    Oct 2 '14 at 16:35
















  • 16





    Just a note, the main reason to use Vi is because Vim isn't installed. If you have Vim installed, it's probably worth using that instead. There isn't really an advantage to Vi besides that it is already present on every Unix install. The best way to learn Vim in my opinion is to open your terminal emulator (not from within Vim) and type vimtutor It will get you up to speed to where it's usable to you in about 45 minutes.

    – Ben Mordecai
    Feb 16 '13 at 18:58






  • 1





    +1 @BenMordecai - I was already familiar with vi (from old), including its convenient sub-shell capability, but needed that refresh. Great little bit of tutoring. Went through it like a breeze. Thanks.

    – Cbhihe
    Oct 2 '14 at 16:35










16




16





Just a note, the main reason to use Vi is because Vim isn't installed. If you have Vim installed, it's probably worth using that instead. There isn't really an advantage to Vi besides that it is already present on every Unix install. The best way to learn Vim in my opinion is to open your terminal emulator (not from within Vim) and type vimtutor It will get you up to speed to where it's usable to you in about 45 minutes.

– Ben Mordecai
Feb 16 '13 at 18:58





Just a note, the main reason to use Vi is because Vim isn't installed. If you have Vim installed, it's probably worth using that instead. There isn't really an advantage to Vi besides that it is already present on every Unix install. The best way to learn Vim in my opinion is to open your terminal emulator (not from within Vim) and type vimtutor It will get you up to speed to where it's usable to you in about 45 minutes.

– Ben Mordecai
Feb 16 '13 at 18:58




1




1





+1 @BenMordecai - I was already familiar with vi (from old), including its convenient sub-shell capability, but needed that refresh. Great little bit of tutoring. Went through it like a breeze. Thanks.

– Cbhihe
Oct 2 '14 at 16:35







+1 @BenMordecai - I was already familiar with vi (from old), including its convenient sub-shell capability, but needed that refresh. Great little bit of tutoring. Went through it like a breeze. Thanks.

– Cbhihe
Oct 2 '14 at 16:35












11 Answers
11






active

oldest

votes


















165














First, make sure you're in edit mode (press i). Then you can paste with Ctrl+Shift+V, if you're in a terminal emulator like gnome-terminal (or select "Paste" from the right-click menu).



You can also type :set paste in vim before you paste to disable automated indenting, etc. Then :set nopaste after you've pasted the content.



Also check this question on stackoverflow.com for more information.



If you want to copy/paste lines in vim (as opposed to pasting clipboard content), you'll want to check out the yank command. Here is a cheat sheet that might help.






share|improve this answer


























  • I think if you have mouse cursor on, you cannot paste using Ctrl+Shift+V.

    – Alvin Wong
    Feb 16 '13 at 14:34






  • 14





    Just a note, the I is case-sensitive. The lowercase i is the normal way of entering insert mode. Capital I brings the cursor to the beginning of the line and then enters you into insert mode.

    – Ben Mordecai
    Feb 16 '13 at 19:01



















60














Vi (and Vim) works very differently compared to a normal text editor such as Gedit. It also has a pretty steep learning curve. If you want to learn some basic commands, start with this interactive tutorial.



However, to answer you question. The system clipboard's content can be accessed through the plus register. So to paste something from the system clipboard you can, from the Normal mode, press: "+p (Not at the same time, but one after another).






share|improve this answer





















  • 3





    This is something I did not know till now. Also, +1 for linking yet another awesome vim tutorial.

    – Attila O.
    Feb 16 '13 at 8:37






  • 19





    Speaking of learning curves for editors, there is the "classical learning curves for some common editors", blog.thilelli.net/public/store/attached/curves.jpg.

    – hlovdal
    Feb 16 '13 at 15:02











  • In GNOME Terminal, the short-cuts for copy and paste are Ctrl-Shift-C and Ctrl-Shift-V, respectively.

    – Flimm
    Feb 23 '13 at 9:17






  • 1





    I've tried to press in turn <kbd>"</kbd>, <kbd>+</kbd> and <kbd>p</kbd>, also <kbd>"</kbd> and <kbd>p</kbd> and nothing has happened. What I've done wrong? I use vi not vim

    – user907860
    Dec 13 '13 at 13:51








  • 1





    That's the right answer. Using eg. Ctrl-Shift-v will work only with the simplest contents (line breaks and indentations can get really wrong if you're in the terminal, and you forgot to use set :paste).

    – rsenna
    Mar 11 '18 at 17:37





















25















  1. If you want to copy paste contents within the same file, use yank and paste.


  2. If you want to copy paste contents across terminals, open the first file, yanking the text you want, then open your second file within vim (e.g. :tabnew /path/to/second/file) and press p to paste it.



  3. If you want to copy paste contents from vim to an external program, you need to access the system clipboard. I assume you use Ubuntu. The GUI version of vim always has clipboard support, however, if you like to use Vim from a terminal, you will have to check for X11-clipboard support.



    From the console, type:



    $ vim --version | grep xterm


    If you find -xterm_clipboard, you have two options:



    1) Compile vim yourself, with the xterm_clipboard flag on



    2) Uninstall vim, install gvim (vim-gtk or vim-gnome) instead. You can stick to non-gui vim by calling vim from the terminal, the same way you did before. This time when you check you should find +xterm_clipborad.



    Now, when you yank some text in the + register inside your vim editor (e.g. "+yy), it also gets copied to the system clipboard which you can retrieve from your external program like gedit editor, by using Ctrl+V.




  4. If you want to copy paste contents from an external program into vim, first copy your text into system clipboard via Ctrl+C, then in vim editor insert mode, click the mouse middle button (usually the wheel) or press Ctrl+Shift+V to paste.



    These are 4 basic copy & paste conditions related to vim. I hope this helps.








share|improve this answer


























  • What's the point of :tabnew /path/to/second/file ? You can achieve the exact same thing yanking/copying/cutting in first file, opening the second file with :vi /path/to/second/file and pasting (p/P) in it. At least in my case... Or is it because I do have the +xterm_clipboard vim feature enabled ? Or is there more to tabnew than just that ?

    – Cbhihe
    Oct 2 '14 at 17:39






  • 1





    On Ubuntu vim-gtk has xterm_clipboard support and on Fedora xvim has it.

    – icc97
    Jun 18 '18 at 1:58



















16














I always use Shift+Insert when I want to paste text into the terminal, works in all terminal programs.



(Which is also the reason why I never get a laptop where you can't press Insert without pressing a secondary key)






share|improve this answer





















  • 2





    Vi/Vim != terminal ;)

    – 0xC0000022L
    Feb 17 '13 at 17:01






  • 1





    ok ok, but it still works :)

    – Magnus Jonsson
    Feb 17 '13 at 17:11











  • +1 for this.. What do you use to perform say Ctrl+A,Ctrl+C also ?

    – Arup Rakshit
    Dec 28 '13 at 18:18











  • If I use a terminal inside a DE I usually just select text with the mouse and copy with Ctrl+Shift+C.

    – Magnus Jonsson
    Jan 2 '14 at 14:38











  • Shift+Insert also works in gvim. (I'm running Ubuntu 13.10, if that makes any difference.)

    – eksortso
    Jan 20 '14 at 17:27



















10














Use the center button of the mouse to insert text you've highlighted elsewhere.



It is useful when you don't have access to your system clipboard (for example, in a remote SSH session).



Must be in edit/insert mode for Vim.






share|improve this answer

































    5














    Once you enter vi, press i to get into insert mode, right click into terminal, click paste.






    share|improve this answer


























    • I thought was lower-case i. What does upper-case I do?

      – Flimm
      Feb 23 '13 at 9:16











    • @Flimm that was already explained in a comment by Ben Mordecai on another answer.

      – sierrasdetandil
      Feb 23 '13 at 19:42











    • I've edited the answer to be lower-case i. Upper-case I moves the cursor to the beginning of the line before entering insert mode, which is not needed here.

      – Flimm
      Feb 23 '13 at 20:04



















    5














    Detailed instructions to copy/paste lines of text in vi using yank and put



    (use the following in the command mode of vi)



    Copy (YANK)



    To copy one line in vi:




    • In the command mode, move the cursor to the line that needs to be copied and type yy or type Y


    To copy 2 lines in vi:




    • In the command mode, move the cursor to the first line that needs to be copied and type 2yy or type 2Y


    (likewise, any number of lines can be copied)



    To copy all lines from the current location to the end of the file:




    • In the command mode, move the cursor to the first line that needs to be copied and type yG


    To copy all text from the current location to the end of the current word:




    • In the command mode, move the cursor to location from where text needs to be copied and type yw


    To copy all text from the current location to the end of the line:




    • In the command mode, move the cursor to location from where text needs to be copied and type y$


    Paste (PUT)



    To paste text in the clipboard - after the location of the cursor:




    • In the command mode, type p


    To paste text in the clipboard - before the location of the cursor:




    • In the command mode, type P






    share|improve this answer

































      1














      I had an issue, because my Vim installation was not supporting the clipboard:



      vim --version | grep clip
      -clipboard +insert_expand +path_extra +user_commands
      +emacs_tags -mouseshape +startuptime -xterm_clipboard


      I installed vim-gnome (which supports the clipboard) and then checked again:



      vim --version | grep clipboard
      +clipboard +insert_expand +path_extra +user_commands
      +emacs_tags +mouseshape +startuptime +xterm_clipboard


      Now I am able to copy and paste using "+y and "+p respectively.






      share|improve this answer


























      • This fixed my problem!

        – astrojuanlu
        Nov 12 '18 at 9:27



















      0














      If you're root: Ctrl+Shift+V



      If you're not-root: Center click the mouse.






      share|improve this answer































        0














        I just wanted to note that using Vim via Git Bash on Windows, you can just use p or center-click of the mouse without being in insert mode. Using Vim through PuTTY, you can just right click. And highlighting does the copying.



        I've noted this because I got here not seeing that this is SE for Ubuntu.



        Other helpful commands:





        • yy(# of lines) - yank (copy)


        • dd(# of lines) - delete


        • p - paste line below current line


        • Shift + p - paste line above current line


        • u - undo


        • r - redo


        • i - insert mode


        • v - visual mode






        share|improve this answer

































          0














          You could use Ctrl+Shift+V to paste in terminal version vim, But for GUI version vim like Neovim-Qt, pasting text from the system clipboard with Ctrl+Shift+V simply won't work. You have to access to the clipboard "+ or "* in the vim editor.



          Adding new keybinding in .vimrc will simply the copy/paste commands:



          " paste from system clipboard, align indentation with surroundings
          noremap <Leader>p "*]p:set nopaste<CR>
          " copy a sentence into system clipboard
          noremap <Leader>y "+y)





          share|improve this answer


























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f256782%2fhow-to-copy-paste-contents-in-the-vi-editor%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            11 Answers
            11






            active

            oldest

            votes








            11 Answers
            11






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            165














            First, make sure you're in edit mode (press i). Then you can paste with Ctrl+Shift+V, if you're in a terminal emulator like gnome-terminal (or select "Paste" from the right-click menu).



            You can also type :set paste in vim before you paste to disable automated indenting, etc. Then :set nopaste after you've pasted the content.



            Also check this question on stackoverflow.com for more information.



            If you want to copy/paste lines in vim (as opposed to pasting clipboard content), you'll want to check out the yank command. Here is a cheat sheet that might help.






            share|improve this answer


























            • I think if you have mouse cursor on, you cannot paste using Ctrl+Shift+V.

              – Alvin Wong
              Feb 16 '13 at 14:34






            • 14





              Just a note, the I is case-sensitive. The lowercase i is the normal way of entering insert mode. Capital I brings the cursor to the beginning of the line and then enters you into insert mode.

              – Ben Mordecai
              Feb 16 '13 at 19:01
















            165














            First, make sure you're in edit mode (press i). Then you can paste with Ctrl+Shift+V, if you're in a terminal emulator like gnome-terminal (or select "Paste" from the right-click menu).



            You can also type :set paste in vim before you paste to disable automated indenting, etc. Then :set nopaste after you've pasted the content.



            Also check this question on stackoverflow.com for more information.



            If you want to copy/paste lines in vim (as opposed to pasting clipboard content), you'll want to check out the yank command. Here is a cheat sheet that might help.






            share|improve this answer


























            • I think if you have mouse cursor on, you cannot paste using Ctrl+Shift+V.

              – Alvin Wong
              Feb 16 '13 at 14:34






            • 14





              Just a note, the I is case-sensitive. The lowercase i is the normal way of entering insert mode. Capital I brings the cursor to the beginning of the line and then enters you into insert mode.

              – Ben Mordecai
              Feb 16 '13 at 19:01














            165












            165








            165







            First, make sure you're in edit mode (press i). Then you can paste with Ctrl+Shift+V, if you're in a terminal emulator like gnome-terminal (or select "Paste" from the right-click menu).



            You can also type :set paste in vim before you paste to disable automated indenting, etc. Then :set nopaste after you've pasted the content.



            Also check this question on stackoverflow.com for more information.



            If you want to copy/paste lines in vim (as opposed to pasting clipboard content), you'll want to check out the yank command. Here is a cheat sheet that might help.






            share|improve this answer















            First, make sure you're in edit mode (press i). Then you can paste with Ctrl+Shift+V, if you're in a terminal emulator like gnome-terminal (or select "Paste" from the right-click menu).



            You can also type :set paste in vim before you paste to disable automated indenting, etc. Then :set nopaste after you've pasted the content.



            Also check this question on stackoverflow.com for more information.



            If you want to copy/paste lines in vim (as opposed to pasting clipboard content), you'll want to check out the yank command. Here is a cheat sheet that might help.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Apr 25 '18 at 22:22









            tambre

            1034




            1034










            answered Feb 16 '13 at 8:27









            Attila O.Attila O.

            2,22411216




            2,22411216













            • I think if you have mouse cursor on, you cannot paste using Ctrl+Shift+V.

              – Alvin Wong
              Feb 16 '13 at 14:34






            • 14





              Just a note, the I is case-sensitive. The lowercase i is the normal way of entering insert mode. Capital I brings the cursor to the beginning of the line and then enters you into insert mode.

              – Ben Mordecai
              Feb 16 '13 at 19:01



















            • I think if you have mouse cursor on, you cannot paste using Ctrl+Shift+V.

              – Alvin Wong
              Feb 16 '13 at 14:34






            • 14





              Just a note, the I is case-sensitive. The lowercase i is the normal way of entering insert mode. Capital I brings the cursor to the beginning of the line and then enters you into insert mode.

              – Ben Mordecai
              Feb 16 '13 at 19:01

















            I think if you have mouse cursor on, you cannot paste using Ctrl+Shift+V.

            – Alvin Wong
            Feb 16 '13 at 14:34





            I think if you have mouse cursor on, you cannot paste using Ctrl+Shift+V.

            – Alvin Wong
            Feb 16 '13 at 14:34




            14




            14





            Just a note, the I is case-sensitive. The lowercase i is the normal way of entering insert mode. Capital I brings the cursor to the beginning of the line and then enters you into insert mode.

            – Ben Mordecai
            Feb 16 '13 at 19:01





            Just a note, the I is case-sensitive. The lowercase i is the normal way of entering insert mode. Capital I brings the cursor to the beginning of the line and then enters you into insert mode.

            – Ben Mordecai
            Feb 16 '13 at 19:01













            60














            Vi (and Vim) works very differently compared to a normal text editor such as Gedit. It also has a pretty steep learning curve. If you want to learn some basic commands, start with this interactive tutorial.



            However, to answer you question. The system clipboard's content can be accessed through the plus register. So to paste something from the system clipboard you can, from the Normal mode, press: "+p (Not at the same time, but one after another).






            share|improve this answer





















            • 3





              This is something I did not know till now. Also, +1 for linking yet another awesome vim tutorial.

              – Attila O.
              Feb 16 '13 at 8:37






            • 19





              Speaking of learning curves for editors, there is the "classical learning curves for some common editors", blog.thilelli.net/public/store/attached/curves.jpg.

              – hlovdal
              Feb 16 '13 at 15:02











            • In GNOME Terminal, the short-cuts for copy and paste are Ctrl-Shift-C and Ctrl-Shift-V, respectively.

              – Flimm
              Feb 23 '13 at 9:17






            • 1





              I've tried to press in turn <kbd>"</kbd>, <kbd>+</kbd> and <kbd>p</kbd>, also <kbd>"</kbd> and <kbd>p</kbd> and nothing has happened. What I've done wrong? I use vi not vim

              – user907860
              Dec 13 '13 at 13:51








            • 1





              That's the right answer. Using eg. Ctrl-Shift-v will work only with the simplest contents (line breaks and indentations can get really wrong if you're in the terminal, and you forgot to use set :paste).

              – rsenna
              Mar 11 '18 at 17:37


















            60














            Vi (and Vim) works very differently compared to a normal text editor such as Gedit. It also has a pretty steep learning curve. If you want to learn some basic commands, start with this interactive tutorial.



            However, to answer you question. The system clipboard's content can be accessed through the plus register. So to paste something from the system clipboard you can, from the Normal mode, press: "+p (Not at the same time, but one after another).






            share|improve this answer





















            • 3





              This is something I did not know till now. Also, +1 for linking yet another awesome vim tutorial.

              – Attila O.
              Feb 16 '13 at 8:37






            • 19





              Speaking of learning curves for editors, there is the "classical learning curves for some common editors", blog.thilelli.net/public/store/attached/curves.jpg.

              – hlovdal
              Feb 16 '13 at 15:02











            • In GNOME Terminal, the short-cuts for copy and paste are Ctrl-Shift-C and Ctrl-Shift-V, respectively.

              – Flimm
              Feb 23 '13 at 9:17






            • 1





              I've tried to press in turn <kbd>"</kbd>, <kbd>+</kbd> and <kbd>p</kbd>, also <kbd>"</kbd> and <kbd>p</kbd> and nothing has happened. What I've done wrong? I use vi not vim

              – user907860
              Dec 13 '13 at 13:51








            • 1





              That's the right answer. Using eg. Ctrl-Shift-v will work only with the simplest contents (line breaks and indentations can get really wrong if you're in the terminal, and you forgot to use set :paste).

              – rsenna
              Mar 11 '18 at 17:37
















            60












            60








            60







            Vi (and Vim) works very differently compared to a normal text editor such as Gedit. It also has a pretty steep learning curve. If you want to learn some basic commands, start with this interactive tutorial.



            However, to answer you question. The system clipboard's content can be accessed through the plus register. So to paste something from the system clipboard you can, from the Normal mode, press: "+p (Not at the same time, but one after another).






            share|improve this answer















            Vi (and Vim) works very differently compared to a normal text editor such as Gedit. It also has a pretty steep learning curve. If you want to learn some basic commands, start with this interactive tutorial.



            However, to answer you question. The system clipboard's content can be accessed through the plus register. So to paste something from the system clipboard you can, from the Normal mode, press: "+p (Not at the same time, but one after another).







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 16 '13 at 16:13

























            answered Feb 16 '13 at 8:34









            Daniel JonssonDaniel Jonsson

            937820




            937820








            • 3





              This is something I did not know till now. Also, +1 for linking yet another awesome vim tutorial.

              – Attila O.
              Feb 16 '13 at 8:37






            • 19





              Speaking of learning curves for editors, there is the "classical learning curves for some common editors", blog.thilelli.net/public/store/attached/curves.jpg.

              – hlovdal
              Feb 16 '13 at 15:02











            • In GNOME Terminal, the short-cuts for copy and paste are Ctrl-Shift-C and Ctrl-Shift-V, respectively.

              – Flimm
              Feb 23 '13 at 9:17






            • 1





              I've tried to press in turn <kbd>"</kbd>, <kbd>+</kbd> and <kbd>p</kbd>, also <kbd>"</kbd> and <kbd>p</kbd> and nothing has happened. What I've done wrong? I use vi not vim

              – user907860
              Dec 13 '13 at 13:51








            • 1





              That's the right answer. Using eg. Ctrl-Shift-v will work only with the simplest contents (line breaks and indentations can get really wrong if you're in the terminal, and you forgot to use set :paste).

              – rsenna
              Mar 11 '18 at 17:37
















            • 3





              This is something I did not know till now. Also, +1 for linking yet another awesome vim tutorial.

              – Attila O.
              Feb 16 '13 at 8:37






            • 19





              Speaking of learning curves for editors, there is the "classical learning curves for some common editors", blog.thilelli.net/public/store/attached/curves.jpg.

              – hlovdal
              Feb 16 '13 at 15:02











            • In GNOME Terminal, the short-cuts for copy and paste are Ctrl-Shift-C and Ctrl-Shift-V, respectively.

              – Flimm
              Feb 23 '13 at 9:17






            • 1





              I've tried to press in turn <kbd>"</kbd>, <kbd>+</kbd> and <kbd>p</kbd>, also <kbd>"</kbd> and <kbd>p</kbd> and nothing has happened. What I've done wrong? I use vi not vim

              – user907860
              Dec 13 '13 at 13:51








            • 1





              That's the right answer. Using eg. Ctrl-Shift-v will work only with the simplest contents (line breaks and indentations can get really wrong if you're in the terminal, and you forgot to use set :paste).

              – rsenna
              Mar 11 '18 at 17:37










            3




            3





            This is something I did not know till now. Also, +1 for linking yet another awesome vim tutorial.

            – Attila O.
            Feb 16 '13 at 8:37





            This is something I did not know till now. Also, +1 for linking yet another awesome vim tutorial.

            – Attila O.
            Feb 16 '13 at 8:37




            19




            19





            Speaking of learning curves for editors, there is the "classical learning curves for some common editors", blog.thilelli.net/public/store/attached/curves.jpg.

            – hlovdal
            Feb 16 '13 at 15:02





            Speaking of learning curves for editors, there is the "classical learning curves for some common editors", blog.thilelli.net/public/store/attached/curves.jpg.

            – hlovdal
            Feb 16 '13 at 15:02













            In GNOME Terminal, the short-cuts for copy and paste are Ctrl-Shift-C and Ctrl-Shift-V, respectively.

            – Flimm
            Feb 23 '13 at 9:17





            In GNOME Terminal, the short-cuts for copy and paste are Ctrl-Shift-C and Ctrl-Shift-V, respectively.

            – Flimm
            Feb 23 '13 at 9:17




            1




            1





            I've tried to press in turn <kbd>"</kbd>, <kbd>+</kbd> and <kbd>p</kbd>, also <kbd>"</kbd> and <kbd>p</kbd> and nothing has happened. What I've done wrong? I use vi not vim

            – user907860
            Dec 13 '13 at 13:51







            I've tried to press in turn <kbd>"</kbd>, <kbd>+</kbd> and <kbd>p</kbd>, also <kbd>"</kbd> and <kbd>p</kbd> and nothing has happened. What I've done wrong? I use vi not vim

            – user907860
            Dec 13 '13 at 13:51






            1




            1





            That's the right answer. Using eg. Ctrl-Shift-v will work only with the simplest contents (line breaks and indentations can get really wrong if you're in the terminal, and you forgot to use set :paste).

            – rsenna
            Mar 11 '18 at 17:37







            That's the right answer. Using eg. Ctrl-Shift-v will work only with the simplest contents (line breaks and indentations can get really wrong if you're in the terminal, and you forgot to use set :paste).

            – rsenna
            Mar 11 '18 at 17:37













            25















            1. If you want to copy paste contents within the same file, use yank and paste.


            2. If you want to copy paste contents across terminals, open the first file, yanking the text you want, then open your second file within vim (e.g. :tabnew /path/to/second/file) and press p to paste it.



            3. If you want to copy paste contents from vim to an external program, you need to access the system clipboard. I assume you use Ubuntu. The GUI version of vim always has clipboard support, however, if you like to use Vim from a terminal, you will have to check for X11-clipboard support.



              From the console, type:



              $ vim --version | grep xterm


              If you find -xterm_clipboard, you have two options:



              1) Compile vim yourself, with the xterm_clipboard flag on



              2) Uninstall vim, install gvim (vim-gtk or vim-gnome) instead. You can stick to non-gui vim by calling vim from the terminal, the same way you did before. This time when you check you should find +xterm_clipborad.



              Now, when you yank some text in the + register inside your vim editor (e.g. "+yy), it also gets copied to the system clipboard which you can retrieve from your external program like gedit editor, by using Ctrl+V.




            4. If you want to copy paste contents from an external program into vim, first copy your text into system clipboard via Ctrl+C, then in vim editor insert mode, click the mouse middle button (usually the wheel) or press Ctrl+Shift+V to paste.



              These are 4 basic copy & paste conditions related to vim. I hope this helps.








            share|improve this answer


























            • What's the point of :tabnew /path/to/second/file ? You can achieve the exact same thing yanking/copying/cutting in first file, opening the second file with :vi /path/to/second/file and pasting (p/P) in it. At least in my case... Or is it because I do have the +xterm_clipboard vim feature enabled ? Or is there more to tabnew than just that ?

              – Cbhihe
              Oct 2 '14 at 17:39






            • 1





              On Ubuntu vim-gtk has xterm_clipboard support and on Fedora xvim has it.

              – icc97
              Jun 18 '18 at 1:58
















            25















            1. If you want to copy paste contents within the same file, use yank and paste.


            2. If you want to copy paste contents across terminals, open the first file, yanking the text you want, then open your second file within vim (e.g. :tabnew /path/to/second/file) and press p to paste it.



            3. If you want to copy paste contents from vim to an external program, you need to access the system clipboard. I assume you use Ubuntu. The GUI version of vim always has clipboard support, however, if you like to use Vim from a terminal, you will have to check for X11-clipboard support.



              From the console, type:



              $ vim --version | grep xterm


              If you find -xterm_clipboard, you have two options:



              1) Compile vim yourself, with the xterm_clipboard flag on



              2) Uninstall vim, install gvim (vim-gtk or vim-gnome) instead. You can stick to non-gui vim by calling vim from the terminal, the same way you did before. This time when you check you should find +xterm_clipborad.



              Now, when you yank some text in the + register inside your vim editor (e.g. "+yy), it also gets copied to the system clipboard which you can retrieve from your external program like gedit editor, by using Ctrl+V.




            4. If you want to copy paste contents from an external program into vim, first copy your text into system clipboard via Ctrl+C, then in vim editor insert mode, click the mouse middle button (usually the wheel) or press Ctrl+Shift+V to paste.



              These are 4 basic copy & paste conditions related to vim. I hope this helps.








            share|improve this answer


























            • What's the point of :tabnew /path/to/second/file ? You can achieve the exact same thing yanking/copying/cutting in first file, opening the second file with :vi /path/to/second/file and pasting (p/P) in it. At least in my case... Or is it because I do have the +xterm_clipboard vim feature enabled ? Or is there more to tabnew than just that ?

              – Cbhihe
              Oct 2 '14 at 17:39






            • 1





              On Ubuntu vim-gtk has xterm_clipboard support and on Fedora xvim has it.

              – icc97
              Jun 18 '18 at 1:58














            25












            25








            25








            1. If you want to copy paste contents within the same file, use yank and paste.


            2. If you want to copy paste contents across terminals, open the first file, yanking the text you want, then open your second file within vim (e.g. :tabnew /path/to/second/file) and press p to paste it.



            3. If you want to copy paste contents from vim to an external program, you need to access the system clipboard. I assume you use Ubuntu. The GUI version of vim always has clipboard support, however, if you like to use Vim from a terminal, you will have to check for X11-clipboard support.



              From the console, type:



              $ vim --version | grep xterm


              If you find -xterm_clipboard, you have two options:



              1) Compile vim yourself, with the xterm_clipboard flag on



              2) Uninstall vim, install gvim (vim-gtk or vim-gnome) instead. You can stick to non-gui vim by calling vim from the terminal, the same way you did before. This time when you check you should find +xterm_clipborad.



              Now, when you yank some text in the + register inside your vim editor (e.g. "+yy), it also gets copied to the system clipboard which you can retrieve from your external program like gedit editor, by using Ctrl+V.




            4. If you want to copy paste contents from an external program into vim, first copy your text into system clipboard via Ctrl+C, then in vim editor insert mode, click the mouse middle button (usually the wheel) or press Ctrl+Shift+V to paste.



              These are 4 basic copy & paste conditions related to vim. I hope this helps.








            share|improve this answer
















            1. If you want to copy paste contents within the same file, use yank and paste.


            2. If you want to copy paste contents across terminals, open the first file, yanking the text you want, then open your second file within vim (e.g. :tabnew /path/to/second/file) and press p to paste it.



            3. If you want to copy paste contents from vim to an external program, you need to access the system clipboard. I assume you use Ubuntu. The GUI version of vim always has clipboard support, however, if you like to use Vim from a terminal, you will have to check for X11-clipboard support.



              From the console, type:



              $ vim --version | grep xterm


              If you find -xterm_clipboard, you have two options:



              1) Compile vim yourself, with the xterm_clipboard flag on



              2) Uninstall vim, install gvim (vim-gtk or vim-gnome) instead. You can stick to non-gui vim by calling vim from the terminal, the same way you did before. This time when you check you should find +xterm_clipborad.



              Now, when you yank some text in the + register inside your vim editor (e.g. "+yy), it also gets copied to the system clipboard which you can retrieve from your external program like gedit editor, by using Ctrl+V.




            4. If you want to copy paste contents from an external program into vim, first copy your text into system clipboard via Ctrl+C, then in vim editor insert mode, click the mouse middle button (usually the wheel) or press Ctrl+Shift+V to paste.



              These are 4 basic copy & paste conditions related to vim. I hope this helps.









            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Apr 3 '17 at 3:00









            Rod

            53




            53










            answered Feb 20 '13 at 5:53









            47dev47null47dev47null

            523159




            523159













            • What's the point of :tabnew /path/to/second/file ? You can achieve the exact same thing yanking/copying/cutting in first file, opening the second file with :vi /path/to/second/file and pasting (p/P) in it. At least in my case... Or is it because I do have the +xterm_clipboard vim feature enabled ? Or is there more to tabnew than just that ?

              – Cbhihe
              Oct 2 '14 at 17:39






            • 1





              On Ubuntu vim-gtk has xterm_clipboard support and on Fedora xvim has it.

              – icc97
              Jun 18 '18 at 1:58



















            • What's the point of :tabnew /path/to/second/file ? You can achieve the exact same thing yanking/copying/cutting in first file, opening the second file with :vi /path/to/second/file and pasting (p/P) in it. At least in my case... Or is it because I do have the +xterm_clipboard vim feature enabled ? Or is there more to tabnew than just that ?

              – Cbhihe
              Oct 2 '14 at 17:39






            • 1





              On Ubuntu vim-gtk has xterm_clipboard support and on Fedora xvim has it.

              – icc97
              Jun 18 '18 at 1:58

















            What's the point of :tabnew /path/to/second/file ? You can achieve the exact same thing yanking/copying/cutting in first file, opening the second file with :vi /path/to/second/file and pasting (p/P) in it. At least in my case... Or is it because I do have the +xterm_clipboard vim feature enabled ? Or is there more to tabnew than just that ?

            – Cbhihe
            Oct 2 '14 at 17:39





            What's the point of :tabnew /path/to/second/file ? You can achieve the exact same thing yanking/copying/cutting in first file, opening the second file with :vi /path/to/second/file and pasting (p/P) in it. At least in my case... Or is it because I do have the +xterm_clipboard vim feature enabled ? Or is there more to tabnew than just that ?

            – Cbhihe
            Oct 2 '14 at 17:39




            1




            1





            On Ubuntu vim-gtk has xterm_clipboard support and on Fedora xvim has it.

            – icc97
            Jun 18 '18 at 1:58





            On Ubuntu vim-gtk has xterm_clipboard support and on Fedora xvim has it.

            – icc97
            Jun 18 '18 at 1:58











            16














            I always use Shift+Insert when I want to paste text into the terminal, works in all terminal programs.



            (Which is also the reason why I never get a laptop where you can't press Insert without pressing a secondary key)






            share|improve this answer





















            • 2





              Vi/Vim != terminal ;)

              – 0xC0000022L
              Feb 17 '13 at 17:01






            • 1





              ok ok, but it still works :)

              – Magnus Jonsson
              Feb 17 '13 at 17:11











            • +1 for this.. What do you use to perform say Ctrl+A,Ctrl+C also ?

              – Arup Rakshit
              Dec 28 '13 at 18:18











            • If I use a terminal inside a DE I usually just select text with the mouse and copy with Ctrl+Shift+C.

              – Magnus Jonsson
              Jan 2 '14 at 14:38











            • Shift+Insert also works in gvim. (I'm running Ubuntu 13.10, if that makes any difference.)

              – eksortso
              Jan 20 '14 at 17:27
















            16














            I always use Shift+Insert when I want to paste text into the terminal, works in all terminal programs.



            (Which is also the reason why I never get a laptop where you can't press Insert without pressing a secondary key)






            share|improve this answer





















            • 2





              Vi/Vim != terminal ;)

              – 0xC0000022L
              Feb 17 '13 at 17:01






            • 1





              ok ok, but it still works :)

              – Magnus Jonsson
              Feb 17 '13 at 17:11











            • +1 for this.. What do you use to perform say Ctrl+A,Ctrl+C also ?

              – Arup Rakshit
              Dec 28 '13 at 18:18











            • If I use a terminal inside a DE I usually just select text with the mouse and copy with Ctrl+Shift+C.

              – Magnus Jonsson
              Jan 2 '14 at 14:38











            • Shift+Insert also works in gvim. (I'm running Ubuntu 13.10, if that makes any difference.)

              – eksortso
              Jan 20 '14 at 17:27














            16












            16








            16







            I always use Shift+Insert when I want to paste text into the terminal, works in all terminal programs.



            (Which is also the reason why I never get a laptop where you can't press Insert without pressing a secondary key)






            share|improve this answer















            I always use Shift+Insert when I want to paste text into the terminal, works in all terminal programs.



            (Which is also the reason why I never get a laptop where you can't press Insert without pressing a secondary key)







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 11 '15 at 8:21









            αғsнιη

            24.9k23100161




            24.9k23100161










            answered Feb 17 '13 at 16:59









            Magnus JonssonMagnus Jonsson

            44428




            44428








            • 2





              Vi/Vim != terminal ;)

              – 0xC0000022L
              Feb 17 '13 at 17:01






            • 1





              ok ok, but it still works :)

              – Magnus Jonsson
              Feb 17 '13 at 17:11











            • +1 for this.. What do you use to perform say Ctrl+A,Ctrl+C also ?

              – Arup Rakshit
              Dec 28 '13 at 18:18











            • If I use a terminal inside a DE I usually just select text with the mouse and copy with Ctrl+Shift+C.

              – Magnus Jonsson
              Jan 2 '14 at 14:38











            • Shift+Insert also works in gvim. (I'm running Ubuntu 13.10, if that makes any difference.)

              – eksortso
              Jan 20 '14 at 17:27














            • 2





              Vi/Vim != terminal ;)

              – 0xC0000022L
              Feb 17 '13 at 17:01






            • 1





              ok ok, but it still works :)

              – Magnus Jonsson
              Feb 17 '13 at 17:11











            • +1 for this.. What do you use to perform say Ctrl+A,Ctrl+C also ?

              – Arup Rakshit
              Dec 28 '13 at 18:18











            • If I use a terminal inside a DE I usually just select text with the mouse and copy with Ctrl+Shift+C.

              – Magnus Jonsson
              Jan 2 '14 at 14:38











            • Shift+Insert also works in gvim. (I'm running Ubuntu 13.10, if that makes any difference.)

              – eksortso
              Jan 20 '14 at 17:27








            2




            2





            Vi/Vim != terminal ;)

            – 0xC0000022L
            Feb 17 '13 at 17:01





            Vi/Vim != terminal ;)

            – 0xC0000022L
            Feb 17 '13 at 17:01




            1




            1





            ok ok, but it still works :)

            – Magnus Jonsson
            Feb 17 '13 at 17:11





            ok ok, but it still works :)

            – Magnus Jonsson
            Feb 17 '13 at 17:11













            +1 for this.. What do you use to perform say Ctrl+A,Ctrl+C also ?

            – Arup Rakshit
            Dec 28 '13 at 18:18





            +1 for this.. What do you use to perform say Ctrl+A,Ctrl+C also ?

            – Arup Rakshit
            Dec 28 '13 at 18:18













            If I use a terminal inside a DE I usually just select text with the mouse and copy with Ctrl+Shift+C.

            – Magnus Jonsson
            Jan 2 '14 at 14:38





            If I use a terminal inside a DE I usually just select text with the mouse and copy with Ctrl+Shift+C.

            – Magnus Jonsson
            Jan 2 '14 at 14:38













            Shift+Insert also works in gvim. (I'm running Ubuntu 13.10, if that makes any difference.)

            – eksortso
            Jan 20 '14 at 17:27





            Shift+Insert also works in gvim. (I'm running Ubuntu 13.10, if that makes any difference.)

            – eksortso
            Jan 20 '14 at 17:27











            10














            Use the center button of the mouse to insert text you've highlighted elsewhere.



            It is useful when you don't have access to your system clipboard (for example, in a remote SSH session).



            Must be in edit/insert mode for Vim.






            share|improve this answer






























              10














              Use the center button of the mouse to insert text you've highlighted elsewhere.



              It is useful when you don't have access to your system clipboard (for example, in a remote SSH session).



              Must be in edit/insert mode for Vim.






              share|improve this answer




























                10












                10








                10







                Use the center button of the mouse to insert text you've highlighted elsewhere.



                It is useful when you don't have access to your system clipboard (for example, in a remote SSH session).



                Must be in edit/insert mode for Vim.






                share|improve this answer















                Use the center button of the mouse to insert text you've highlighted elsewhere.



                It is useful when you don't have access to your system clipboard (for example, in a remote SSH session).



                Must be in edit/insert mode for Vim.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jul 19 '18 at 21:26









                Peter Mortensen

                1,03421016




                1,03421016










                answered Feb 16 '13 at 16:09









                will-obwill-ob

                37117




                37117























                    5














                    Once you enter vi, press i to get into insert mode, right click into terminal, click paste.






                    share|improve this answer


























                    • I thought was lower-case i. What does upper-case I do?

                      – Flimm
                      Feb 23 '13 at 9:16











                    • @Flimm that was already explained in a comment by Ben Mordecai on another answer.

                      – sierrasdetandil
                      Feb 23 '13 at 19:42











                    • I've edited the answer to be lower-case i. Upper-case I moves the cursor to the beginning of the line before entering insert mode, which is not needed here.

                      – Flimm
                      Feb 23 '13 at 20:04
















                    5














                    Once you enter vi, press i to get into insert mode, right click into terminal, click paste.






                    share|improve this answer


























                    • I thought was lower-case i. What does upper-case I do?

                      – Flimm
                      Feb 23 '13 at 9:16











                    • @Flimm that was already explained in a comment by Ben Mordecai on another answer.

                      – sierrasdetandil
                      Feb 23 '13 at 19:42











                    • I've edited the answer to be lower-case i. Upper-case I moves the cursor to the beginning of the line before entering insert mode, which is not needed here.

                      – Flimm
                      Feb 23 '13 at 20:04














                    5












                    5








                    5







                    Once you enter vi, press i to get into insert mode, right click into terminal, click paste.






                    share|improve this answer















                    Once you enter vi, press i to get into insert mode, right click into terminal, click paste.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Feb 23 '13 at 20:03









                    Flimm

                    21.9k1563123




                    21.9k1563123










                    answered Feb 17 '13 at 6:34









                    GC 13GC 13

                    255111




                    255111













                    • I thought was lower-case i. What does upper-case I do?

                      – Flimm
                      Feb 23 '13 at 9:16











                    • @Flimm that was already explained in a comment by Ben Mordecai on another answer.

                      – sierrasdetandil
                      Feb 23 '13 at 19:42











                    • I've edited the answer to be lower-case i. Upper-case I moves the cursor to the beginning of the line before entering insert mode, which is not needed here.

                      – Flimm
                      Feb 23 '13 at 20:04



















                    • I thought was lower-case i. What does upper-case I do?

                      – Flimm
                      Feb 23 '13 at 9:16











                    • @Flimm that was already explained in a comment by Ben Mordecai on another answer.

                      – sierrasdetandil
                      Feb 23 '13 at 19:42











                    • I've edited the answer to be lower-case i. Upper-case I moves the cursor to the beginning of the line before entering insert mode, which is not needed here.

                      – Flimm
                      Feb 23 '13 at 20:04

















                    I thought was lower-case i. What does upper-case I do?

                    – Flimm
                    Feb 23 '13 at 9:16





                    I thought was lower-case i. What does upper-case I do?

                    – Flimm
                    Feb 23 '13 at 9:16













                    @Flimm that was already explained in a comment by Ben Mordecai on another answer.

                    – sierrasdetandil
                    Feb 23 '13 at 19:42





                    @Flimm that was already explained in a comment by Ben Mordecai on another answer.

                    – sierrasdetandil
                    Feb 23 '13 at 19:42













                    I've edited the answer to be lower-case i. Upper-case I moves the cursor to the beginning of the line before entering insert mode, which is not needed here.

                    – Flimm
                    Feb 23 '13 at 20:04





                    I've edited the answer to be lower-case i. Upper-case I moves the cursor to the beginning of the line before entering insert mode, which is not needed here.

                    – Flimm
                    Feb 23 '13 at 20:04











                    5














                    Detailed instructions to copy/paste lines of text in vi using yank and put



                    (use the following in the command mode of vi)



                    Copy (YANK)



                    To copy one line in vi:




                    • In the command mode, move the cursor to the line that needs to be copied and type yy or type Y


                    To copy 2 lines in vi:




                    • In the command mode, move the cursor to the first line that needs to be copied and type 2yy or type 2Y


                    (likewise, any number of lines can be copied)



                    To copy all lines from the current location to the end of the file:




                    • In the command mode, move the cursor to the first line that needs to be copied and type yG


                    To copy all text from the current location to the end of the current word:




                    • In the command mode, move the cursor to location from where text needs to be copied and type yw


                    To copy all text from the current location to the end of the line:




                    • In the command mode, move the cursor to location from where text needs to be copied and type y$


                    Paste (PUT)



                    To paste text in the clipboard - after the location of the cursor:




                    • In the command mode, type p


                    To paste text in the clipboard - before the location of the cursor:




                    • In the command mode, type P






                    share|improve this answer






























                      5














                      Detailed instructions to copy/paste lines of text in vi using yank and put



                      (use the following in the command mode of vi)



                      Copy (YANK)



                      To copy one line in vi:




                      • In the command mode, move the cursor to the line that needs to be copied and type yy or type Y


                      To copy 2 lines in vi:




                      • In the command mode, move the cursor to the first line that needs to be copied and type 2yy or type 2Y


                      (likewise, any number of lines can be copied)



                      To copy all lines from the current location to the end of the file:




                      • In the command mode, move the cursor to the first line that needs to be copied and type yG


                      To copy all text from the current location to the end of the current word:




                      • In the command mode, move the cursor to location from where text needs to be copied and type yw


                      To copy all text from the current location to the end of the line:




                      • In the command mode, move the cursor to location from where text needs to be copied and type y$


                      Paste (PUT)



                      To paste text in the clipboard - after the location of the cursor:




                      • In the command mode, type p


                      To paste text in the clipboard - before the location of the cursor:




                      • In the command mode, type P






                      share|improve this answer




























                        5












                        5








                        5







                        Detailed instructions to copy/paste lines of text in vi using yank and put



                        (use the following in the command mode of vi)



                        Copy (YANK)



                        To copy one line in vi:




                        • In the command mode, move the cursor to the line that needs to be copied and type yy or type Y


                        To copy 2 lines in vi:




                        • In the command mode, move the cursor to the first line that needs to be copied and type 2yy or type 2Y


                        (likewise, any number of lines can be copied)



                        To copy all lines from the current location to the end of the file:




                        • In the command mode, move the cursor to the first line that needs to be copied and type yG


                        To copy all text from the current location to the end of the current word:




                        • In the command mode, move the cursor to location from where text needs to be copied and type yw


                        To copy all text from the current location to the end of the line:




                        • In the command mode, move the cursor to location from where text needs to be copied and type y$


                        Paste (PUT)



                        To paste text in the clipboard - after the location of the cursor:




                        • In the command mode, type p


                        To paste text in the clipboard - before the location of the cursor:




                        • In the command mode, type P






                        share|improve this answer















                        Detailed instructions to copy/paste lines of text in vi using yank and put



                        (use the following in the command mode of vi)



                        Copy (YANK)



                        To copy one line in vi:




                        • In the command mode, move the cursor to the line that needs to be copied and type yy or type Y


                        To copy 2 lines in vi:




                        • In the command mode, move the cursor to the first line that needs to be copied and type 2yy or type 2Y


                        (likewise, any number of lines can be copied)



                        To copy all lines from the current location to the end of the file:




                        • In the command mode, move the cursor to the first line that needs to be copied and type yG


                        To copy all text from the current location to the end of the current word:




                        • In the command mode, move the cursor to location from where text needs to be copied and type yw


                        To copy all text from the current location to the end of the line:




                        • In the command mode, move the cursor to location from where text needs to be copied and type y$


                        Paste (PUT)



                        To paste text in the clipboard - after the location of the cursor:




                        • In the command mode, type p


                        To paste text in the clipboard - before the location of the cursor:




                        • In the command mode, type P







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Nov 3 '13 at 22:09

























                        answered Nov 3 '13 at 21:43









                        slayernoahslayernoah

                        2291310




                        2291310























                            1














                            I had an issue, because my Vim installation was not supporting the clipboard:



                            vim --version | grep clip
                            -clipboard +insert_expand +path_extra +user_commands
                            +emacs_tags -mouseshape +startuptime -xterm_clipboard


                            I installed vim-gnome (which supports the clipboard) and then checked again:



                            vim --version | grep clipboard
                            +clipboard +insert_expand +path_extra +user_commands
                            +emacs_tags +mouseshape +startuptime +xterm_clipboard


                            Now I am able to copy and paste using "+y and "+p respectively.






                            share|improve this answer


























                            • This fixed my problem!

                              – astrojuanlu
                              Nov 12 '18 at 9:27
















                            1














                            I had an issue, because my Vim installation was not supporting the clipboard:



                            vim --version | grep clip
                            -clipboard +insert_expand +path_extra +user_commands
                            +emacs_tags -mouseshape +startuptime -xterm_clipboard


                            I installed vim-gnome (which supports the clipboard) and then checked again:



                            vim --version | grep clipboard
                            +clipboard +insert_expand +path_extra +user_commands
                            +emacs_tags +mouseshape +startuptime +xterm_clipboard


                            Now I am able to copy and paste using "+y and "+p respectively.






                            share|improve this answer


























                            • This fixed my problem!

                              – astrojuanlu
                              Nov 12 '18 at 9:27














                            1












                            1








                            1







                            I had an issue, because my Vim installation was not supporting the clipboard:



                            vim --version | grep clip
                            -clipboard +insert_expand +path_extra +user_commands
                            +emacs_tags -mouseshape +startuptime -xterm_clipboard


                            I installed vim-gnome (which supports the clipboard) and then checked again:



                            vim --version | grep clipboard
                            +clipboard +insert_expand +path_extra +user_commands
                            +emacs_tags +mouseshape +startuptime +xterm_clipboard


                            Now I am able to copy and paste using "+y and "+p respectively.






                            share|improve this answer















                            I had an issue, because my Vim installation was not supporting the clipboard:



                            vim --version | grep clip
                            -clipboard +insert_expand +path_extra +user_commands
                            +emacs_tags -mouseshape +startuptime -xterm_clipboard


                            I installed vim-gnome (which supports the clipboard) and then checked again:



                            vim --version | grep clipboard
                            +clipboard +insert_expand +path_extra +user_commands
                            +emacs_tags +mouseshape +startuptime +xterm_clipboard


                            Now I am able to copy and paste using "+y and "+p respectively.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Jul 19 '18 at 21:27









                            Peter Mortensen

                            1,03421016




                            1,03421016










                            answered Jun 9 '18 at 11:35









                            Ashutosh TripathyAshutosh Tripathy

                            1312




                            1312













                            • This fixed my problem!

                              – astrojuanlu
                              Nov 12 '18 at 9:27



















                            • This fixed my problem!

                              – astrojuanlu
                              Nov 12 '18 at 9:27

















                            This fixed my problem!

                            – astrojuanlu
                            Nov 12 '18 at 9:27





                            This fixed my problem!

                            – astrojuanlu
                            Nov 12 '18 at 9:27











                            0














                            If you're root: Ctrl+Shift+V



                            If you're not-root: Center click the mouse.






                            share|improve this answer




























                              0














                              If you're root: Ctrl+Shift+V



                              If you're not-root: Center click the mouse.






                              share|improve this answer


























                                0












                                0








                                0







                                If you're root: Ctrl+Shift+V



                                If you're not-root: Center click the mouse.






                                share|improve this answer













                                If you're root: Ctrl+Shift+V



                                If you're not-root: Center click the mouse.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Jul 1 '17 at 6:54









                                Elliptical viewElliptical view

                                404312




                                404312























                                    0














                                    I just wanted to note that using Vim via Git Bash on Windows, you can just use p or center-click of the mouse without being in insert mode. Using Vim through PuTTY, you can just right click. And highlighting does the copying.



                                    I've noted this because I got here not seeing that this is SE for Ubuntu.



                                    Other helpful commands:





                                    • yy(# of lines) - yank (copy)


                                    • dd(# of lines) - delete


                                    • p - paste line below current line


                                    • Shift + p - paste line above current line


                                    • u - undo


                                    • r - redo


                                    • i - insert mode


                                    • v - visual mode






                                    share|improve this answer






























                                      0














                                      I just wanted to note that using Vim via Git Bash on Windows, you can just use p or center-click of the mouse without being in insert mode. Using Vim through PuTTY, you can just right click. And highlighting does the copying.



                                      I've noted this because I got here not seeing that this is SE for Ubuntu.



                                      Other helpful commands:





                                      • yy(# of lines) - yank (copy)


                                      • dd(# of lines) - delete


                                      • p - paste line below current line


                                      • Shift + p - paste line above current line


                                      • u - undo


                                      • r - redo


                                      • i - insert mode


                                      • v - visual mode






                                      share|improve this answer




























                                        0












                                        0








                                        0







                                        I just wanted to note that using Vim via Git Bash on Windows, you can just use p or center-click of the mouse without being in insert mode. Using Vim through PuTTY, you can just right click. And highlighting does the copying.



                                        I've noted this because I got here not seeing that this is SE for Ubuntu.



                                        Other helpful commands:





                                        • yy(# of lines) - yank (copy)


                                        • dd(# of lines) - delete


                                        • p - paste line below current line


                                        • Shift + p - paste line above current line


                                        • u - undo


                                        • r - redo


                                        • i - insert mode


                                        • v - visual mode






                                        share|improve this answer















                                        I just wanted to note that using Vim via Git Bash on Windows, you can just use p or center-click of the mouse without being in insert mode. Using Vim through PuTTY, you can just right click. And highlighting does the copying.



                                        I've noted this because I got here not seeing that this is SE for Ubuntu.



                                        Other helpful commands:





                                        • yy(# of lines) - yank (copy)


                                        • dd(# of lines) - delete


                                        • p - paste line below current line


                                        • Shift + p - paste line above current line


                                        • u - undo


                                        • r - redo


                                        • i - insert mode


                                        • v - visual mode







                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        edited Jul 19 '18 at 21:26









                                        Peter Mortensen

                                        1,03421016




                                        1,03421016










                                        answered Jul 21 '17 at 3:27









                                        Tyler ChristianTyler Christian

                                        1013




                                        1013























                                            0














                                            You could use Ctrl+Shift+V to paste in terminal version vim, But for GUI version vim like Neovim-Qt, pasting text from the system clipboard with Ctrl+Shift+V simply won't work. You have to access to the clipboard "+ or "* in the vim editor.



                                            Adding new keybinding in .vimrc will simply the copy/paste commands:



                                            " paste from system clipboard, align indentation with surroundings
                                            noremap <Leader>p "*]p:set nopaste<CR>
                                            " copy a sentence into system clipboard
                                            noremap <Leader>y "+y)





                                            share|improve this answer






























                                              0














                                              You could use Ctrl+Shift+V to paste in terminal version vim, But for GUI version vim like Neovim-Qt, pasting text from the system clipboard with Ctrl+Shift+V simply won't work. You have to access to the clipboard "+ or "* in the vim editor.



                                              Adding new keybinding in .vimrc will simply the copy/paste commands:



                                              " paste from system clipboard, align indentation with surroundings
                                              noremap <Leader>p "*]p:set nopaste<CR>
                                              " copy a sentence into system clipboard
                                              noremap <Leader>y "+y)





                                              share|improve this answer




























                                                0












                                                0








                                                0







                                                You could use Ctrl+Shift+V to paste in terminal version vim, But for GUI version vim like Neovim-Qt, pasting text from the system clipboard with Ctrl+Shift+V simply won't work. You have to access to the clipboard "+ or "* in the vim editor.



                                                Adding new keybinding in .vimrc will simply the copy/paste commands:



                                                " paste from system clipboard, align indentation with surroundings
                                                noremap <Leader>p "*]p:set nopaste<CR>
                                                " copy a sentence into system clipboard
                                                noremap <Leader>y "+y)





                                                share|improve this answer















                                                You could use Ctrl+Shift+V to paste in terminal version vim, But for GUI version vim like Neovim-Qt, pasting text from the system clipboard with Ctrl+Shift+V simply won't work. You have to access to the clipboard "+ or "* in the vim editor.



                                                Adding new keybinding in .vimrc will simply the copy/paste commands:



                                                " paste from system clipboard, align indentation with surroundings
                                                noremap <Leader>p "*]p:set nopaste<CR>
                                                " copy a sentence into system clipboard
                                                noremap <Leader>y "+y)






                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited Mar 19 at 13:23

























                                                answered Mar 19 at 13:18









                                                Yossarian42Yossarian42

                                                112




                                                112






























                                                    draft saved

                                                    draft discarded




















































                                                    Thanks for contributing an answer to Ask Ubuntu!


                                                    • Please be sure to answer the question. Provide details and share your research!

                                                    But avoid



                                                    • Asking for help, clarification, or responding to other answers.

                                                    • Making statements based on opinion; back them up with references or personal experience.


                                                    To learn more, see our tips on writing great answers.




                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function () {
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f256782%2fhow-to-copy-paste-contents-in-the-vi-editor%23new-answer', 'question_page');
                                                    }
                                                    );

                                                    Post as a guest















                                                    Required, but never shown





















































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown

































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown







                                                    Popular posts from this blog

                                                    How did Captain America manage to do this?

                                                    迪纳利

                                                    南乌拉尔铁路局