Copy and Paste to/from Vim from/to Other Programs!

แชร์
ฝัง

ความคิดเห็น • 243

  • @Alendrik
    @Alendrik 2 ปีที่แล้ว +7

    Dude this helped SO much. I've been trying to find this stuff out and all I kept getting was "you never need to clipboard things in and out of vim". So many unhelpful posts read, UNTIL now.
    Not only that, but I also know more about registers and cool pluses of vim. Great video!

  • @RajivLochanPanda
    @RajivLochanPanda 4 ปีที่แล้ว +4

    I read this solution, somewhere on stack overflow, of using '+' register to copy stuff out of vim, without any background on registers in vim, which left me confused.
    Thank you for making it clear! You're an awesome educator! 🙏

  • @SimpleLangSolution
    @SimpleLangSolution 6 ปีที่แล้ว +1

    Where have you been my entire life?
    This channel man. This channel right here.
    Damn, it's so good.

  • @Comrade_Tux
    @Comrade_Tux 2 ปีที่แล้ว

    Wow, You not only answered what I searched, but also taught me a lot about copying and pasting inside vim. Thanks.

  • @-XArchLinuxEnjoyerX-
    @-XArchLinuxEnjoyerX- 5 ปีที่แล้ว +5

    Hey, I just wanted to let you know that I'm a new subscriber and I absolutely love your linux videos. You explain things in a way that makes understanding complex things easy, and your subjects are stuff I dont think I would have found on my own. Thank you

  • @prahe86
    @prahe86 6 ปีที่แล้ว +76

    You're a great teacher.

  • @fernabianer1898
    @fernabianer1898 4 ปีที่แล้ว

    Very well made. I'll rewatch this one later and play around with it. Thank you Luke!

  • @ButthurtNinja
    @ButthurtNinja 6 ปีที่แล้ว +39

    Luke, you're the gift that keeps on giving. freakin love your vids, wouldn't be able to Linux without them
    do not stop or i will find you

    • @finnianquail8881
      @finnianquail8881 6 ปีที่แล้ว +14

      Dusta Rhymes I'd just like to interject for a moment. What you're referring to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX. Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called "Linux", and many of its users are not aware that it is basically the GNU system, developed by the GNU Project. There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called "Linux" distributions are really distributions of GNU/Linux.

    • @bratezoran2102
      @bratezoran2102 4 ปีที่แล้ว +2

      @@finnianquail8881 WHO THE F CARES I CALL IT LINUX STOP ME

    • @minhajshovon9789
      @minhajshovon9789 4 ปีที่แล้ว +3

      @@finnianquail8881 here comes RMS agent :3

    • @rogzinho
      @rogzinho 4 ปีที่แล้ว

      Obey koomer

    • @conceptrat
      @conceptrat 4 ปีที่แล้ว

      @@finnianquail8881 I hear ya but could it not be Linux+GNU as the kernel is loaded first right? 😬

  • @chrest1konto29
    @chrest1konto29 6 ปีที่แล้ว +18

    Sabaton ... a man of culture!

  • @MuhammadUsman-qf7cl
    @MuhammadUsman-qf7cl ปีที่แล้ว

    Thanks Luke, for sharing the valuable information in a simple way, I was really confused, on how to do copy and paste through vim but after watching and implementing at the same time, I am amazed that it really works, my life is pretty simple now, I really appreciate your help.

  • @alcesmir
    @alcesmir 5 ปีที่แล้ว +3

    It's also worth mentioning you can use the "* to access the register corresponding to the primary selection (i.e. the selection you can paste with middle mouse button and set by selecting text).

  • @ViniciusProvenzano
    @ViniciusProvenzano 6 ปีที่แล้ว +4

    This is a good tip. I am using the terminal that I don’t like that much, but that has the shortcut shift control V, so when I need to copy and paste into vim I just press insert and the shortcut. Sometimes also as a workaround inside i3 I would have only one window with vim on split mode instead of having two windows neatly placed. Thanks, it’s much easier now.

  • @kant859600
    @kant859600 4 ปีที่แล้ว +2

    After so many tutorials on internet I found this solution on your channel. Thank you soo much man.

  • @pnuema1.618
    @pnuema1.618 ปีที่แล้ว

    You're a good man! I have been putting this off for a while but the frustration grew beyond my laziness. Luckily this was an easy solution without much effort.

  • @qwertyasdf7615
    @qwertyasdf7615 6 ปีที่แล้ว +34

    neovim comes with sys clipboard access as well

  • @hacerdemirel9833
    @hacerdemirel9833 4 ปีที่แล้ว

    This is what I was looking for by years. Thanks.

  • @jamescritchlow3445
    @jamescritchlow3445 ปีที่แล้ว

    the amount of problems this has solved for me is incredible. who knew that all I needed to do to be able to use windows shortcuts was to install gvim. thankyou kind sir you have earned my subscription

  • @DFsdf3443d
    @DFsdf3443d 5 ปีที่แล้ว +1

    ah the era of me closing vim, opening notepad to copy something over, and then reopening vim is finally over. Thank you sir

  • @Eliotime3000
    @Eliotime3000 4 ปีที่แล้ว

    In GVIM, the contextual menus explains the VIM bindings for cut, copy and paste are shown ("+x for cut, "+y for copy, "+gP for paste) and works in the good ol' VIM.

  • @MM-doremifaso
    @MM-doremifaso 5 ปีที่แล้ว

    I like your music, sabaton forever! 🤘

  • @SArthur221
    @SArthur221 3 ปีที่แล้ว +2

    5:23 C-v is normally block visual select, which i use a ton xD

  • @xbz24
    @xbz24 ปีที่แล้ว

    holy shit. cristal clear like water, thank you dude. FUCK YEAH now I can copy paste from my browser love you dawg

  • @fabriziobertoglio7342
    @fabriziobertoglio7342 5 ปีที่แล้ว +1

    amazing. I m trying this since 2 years :)

  • @jordanmoravenov
    @jordanmoravenov 5 หลายเดือนก่อน

    Thank you! Everything I needed I learned in this video.

  • @ibrahimKaraagac
    @ibrahimKaraagac 6 ปีที่แล้ว +1

    Luke I enjoy your videos and watch every one of. Thank You.

  • @ziggyspaz
    @ziggyspaz 4 ปีที่แล้ว

    Thanks for letting me learn something new today

  • @christbaumer
    @christbaumer 4 ปีที่แล้ว +1

    is used for block visual by default.

  • @VoylinsLife
    @VoylinsLife 2 ปีที่แล้ว

    This explanation was so helpful, I recently started using vim and loving it so far but I couldn't figure out for the life of me how to make this work ^^"

  • @janekiii
    @janekiii 2 ปีที่แล้ว

    read a website that teaches me the same syntax but the lack of context is confusing and this video helps me. TY!

  • @morgansippel2057
    @morgansippel2057 4 ปีที่แล้ว

    thank you so much, its quite funny I just racked my brain for a good hour trying to figure out how to copy and paste in and out of vim, your tutorial was great but from what I understand Im not the only person struggling with gnome desktop, I think Ill have to use gvim, thanks

  • @anirudhrawat7584
    @anirudhrawat7584 2 ปีที่แล้ว

    Thank you for this. Helped a lot.

  • @MatheusCopyright
    @MatheusCopyright 6 ปีที่แล้ว +4

    I used ctrl alt c/ctrl alt v or shift insert to copy/paste, its the terminal clipboard, but it always cut the first letters, finally someone explained how to properly use the registers

  • @Chalisque
    @Chalisque 26 วันที่ผ่านมา

    I have a number of things for a number of use cases. For clipboard access, I have two scripts, pc and pp (for pasteboard copy and pasteboard paste, inspired by the macos commands), which call the relevant clipboard access whether X, Wayland, Macos, Cygwin, or WSL. Then I have a python clipboard server running on my pi3 which has named clipboards I can put to/get from (so e.g. echo hello | aput boing, and then aget boing will recall). This gives me LAN-wide named clipboards. Then another one is similar, cput, (again in Python) which uses a mysql server as its backend, and maintains a history of previously copied text. Another one, dput, uses a PHP backend and has a web interface.
    In vim, I use pp pc to copy lines to/from the clipboard; and have similar mappings for aget, cget, and dget.

  • @4.0.4
    @4.0.4 5 ปีที่แล้ว +13

    The editor I use has these keyboard bindings, Ctrl+C and Ctrl+V, I use them a lot.

    • @wesleyjrz
      @wesleyjrz 2 ปีที่แล้ว +2

      lol

    • @tuananhdo1870
      @tuananhdo1870 2 ปีที่แล้ว

      what is you editor are you using: sublime or vscode?

    • @kaksisve4012
      @kaksisve4012 2 ปีที่แล้ว

      ​@@tuananhdo1870 Provably ED. :D

    • @itsmith32
      @itsmith32 6 หลายเดือนก่อน

      @@tuananhdo1870 Notepad, of course:)))

  • @mkd1113
    @mkd1113 6 ปีที่แล้ว +7

    I'm too lazy to even rebind "+p/y in my vimrc, so I just enter insert mode and use st's built in ctrl+shift+c/v. I also have tmux to select text from my terminal buffer with the keyboard so I don't have to use the mouse.

  • @miguelangelmeditux8785
    @miguelangelmeditux8785 ปีที่แล้ว

    muchas gracias por el video, soy nuevo con Vim y me ha ayudado mucho

  • @sachinwalunjakar8854
    @sachinwalunjakar8854 3 ปีที่แล้ว

    Thanks for making this video.
    Very helpful.

  • @user-zu8vw6cv2b
    @user-zu8vw6cv2b 4 หลายเดือนก่อน

    Straight to the point. Useful. Liked and subscribed

  • @ashish902
    @ashish902 3 ปีที่แล้ว

    Thank you very much. It got so easier now.

  • @kktauke
    @kktauke 4 ปีที่แล้ว

    Nicely done!

  • @YannMetalhead
    @YannMetalhead ปีที่แล้ว

    Good explanation, thank you!

  • @fredklier
    @fredklier 3 ปีที่แล้ว

    So simple and you save a lot of trouble! thanks

  • @macfhlannchadharonan4668
    @macfhlannchadharonan4668 4 ปีที่แล้ว +2

    note a caveat to this is that when using vim over ssh, which many of us usually do, the system clipboard may not work. It also may not work if vim isnt compiled with system clipboard support. To get around this you can make use of the OSC52 escape sequence when send the data encoded to your terminal emulator which saves it to your clipboard.

    • @delta-a17
      @delta-a17 หลายเดือนก่อน

      Could you explain more about this? I know terminal emulators have big long lists of escape sequences buried in their settings but not much more. How does this work?

  • @diegocastillo6470
    @diegocastillo6470 4 ปีที่แล้ว +2

    Just out of instinct I tried issuing "gvim" and when apt said to me that I could install it by installing vim, vim-gtk and other, I was like "Where's gvim?"... Anyway, I installed vim-gtk3 and it includes gvim, now I have acces to the + register. Excelent video

  • @WorldOfNemo
    @WorldOfNemo 6 ปีที่แล้ว

    Great Video !! I actually didn't learn anything but i sure would have loved learning that in this video with you cause you always make it easy and simple. So cool !

  • @RTRed
    @RTRed ปีที่แล้ว

    There is another very simple way to copy/paste text to and from a terminal instance or a browser, for example, using your mouse. Just select what you need to copy using your mouse press 'ctrl+shift+c' to copy from a terminal and ctrl+shift+v to paste to a terminal. However, if you copy something from a terminal, you will have to do the usual ctrl + v on the browser to paste and vice versa. I had this behaviour by default on my Artix Linux install on all terminal emulators, of course barring tty. I am not sure whether it has to be added in other scenarios.

  • @SergioRCerqueira
    @SergioRCerqueira 3 ปีที่แล้ว

    Thx, simple and useful tip.

  • @anassadkaoui1
    @anassadkaoui1 หลายเดือนก่อน

    Damn, it's so good.

  • @saintrivers962
    @saintrivers962 2 ปีที่แล้ว

    thank you so much, this was super helpful.

  • @tranthephong5457
    @tranthephong5457 5 ปีที่แล้ว

    Thanks! You saved my day.

  • @DavidHdezES
    @DavidHdezES 3 ปีที่แล้ว

    God bless you!

  • @bdbs1815
    @bdbs1815 4 หลายเดือนก่อน

    Hell yeah. Thanks for the help.

  • @grantbarthelmes1950
    @grantbarthelmes1950 11 หลายเดือนก่อน

    One of the many heros of the internet

  • @abhijayrajvansh
    @abhijayrajvansh 2 หลายเดือนก่อน

    thanks luke, great help!

  • @smtusharibnesalam8688
    @smtusharibnesalam8688 4 ปีที่แล้ว

    Thank you for helping me out

  • @s9chroma210
    @s9chroma210 4 ปีที่แล้ว

    Saved my life. Thanks

  • @cagataykaydr8019
    @cagataykaydr8019 4 ปีที่แล้ว

    u re a king man

  • @Chalisque
    @Chalisque 26 วันที่ผ่านมา

    If you're on X11, one choice is xsel. For Wayland, wl-paste. For cygwin you write to or read from /dev/clipboard. For macos there is pbcopy and pbpaste. (So I have as I mentioned earlier, two scripts pp and pc which choose the appropriate way to deal with the clipboard.)

  • @alexrazz1234
    @alexrazz1234 6 ปีที่แล้ว

    Very informative, thanks

  • @galk32
    @galk32 2 ปีที่แล้ว

    Great tutorial

  • @miika35476
    @miika35476 3 ปีที่แล้ว

    Thank you! I love vim, but missing that copy paste thing drove me crazy. :D

  • @TheEmbeddedLinuxDude
    @TheEmbeddedLinuxDude 5 ปีที่แล้ว

    Thx! Great Explanation!

  • @desktorp
    @desktorp 6 ปีที่แล้ว +2

    3:15 "So I'm gonna close out of this and then I'll be right back"
    "Okay so I've showered and I still feel dirty so I'll just end this video now."

  • @Chalisque
    @Chalisque 26 วันที่ผ่านมา

    The root of a general solution is :w and :r. You can select some lies, then :w !myprog, and this will pipe the selected lines to the stdin of myproc. Note the space comes after the :w but before the !. Then :r! myprog will run myprog and paste the stdout into your vim buffer below the current line. Note this time that the space comes after the !. What wonderful consistency. Also when you have some lines selected via visual, :!myprog will pipe those lies into myprog's stdin, and then replace the selection with myprog's stdout.

  • @youngun550
    @youngun550 9 หลายเดือนก่อน

    What does

  • @buntun3670
    @buntun3670 5 หลายเดือนก่อน

    this was great

  • @pepsiplease69
    @pepsiplease69 ปีที่แล้ว +1

    I’m sure that you already know, but you can set the option like “:set clipboard=unnamed” or in some cases set it to “unnamedplus”. Once this is done, anything you yank or paste will go to/from your system clipboard without you having to do “* every time or even creating a mapping that does that.

    • @matty3501
      @matty3501 ปีที่แล้ว

      I have tried many variations of this on my system and it doesn't seem to work, I don't know if it is distro dependent or requires some random software I don't have. (using debian 11)
      edit: lol unnamedplus does the trick, thank you stranger!

    • @kamehameha38
      @kamehameha38 ปีที่แล้ว +2

      But then you lose the utility of having different clipboard registers.

    • @Degist
      @Degist 8 หลายเดือนก่อน

      @@kamehameha38 It's no utility, to me it's complete stupidity and making life difficult for people.

  • @HadToChangeMyName_YoutubeSucks
    @HadToChangeMyName_YoutubeSucks 5 ปีที่แล้ว

    I was just this morning wanting to copy more than would fit on my terminal from vim this morning into something. Obviously if it's just something that fits on a screen I can use the mouse to copy but when it's more than a screenful I can't. Thanks. Had to install gvim (which actually requires installing vim-gnome, there is no gvim in the repo)

  • @thelowendstudio
    @thelowendstudio ปีที่แล้ว

    Many tanks :>

  • @TheEbbemonster
    @TheEbbemonster 2 ปีที่แล้ว +1

    Great explanation! Unfortunately it is a nightmare to get working on WSL :(

  • @ali-om4uv
    @ali-om4uv 6 ปีที่แล้ว +1

    Great Video! I have a question tho: I am currently working on a HPC running CentOS 7.3 . A takst i have to do quite often is to copy something from the terminal and paste it in Vim. For example the output of the "pwd" command. At the moment i highlight the text with the mouse, which paste it to the clipboard i guess, and than i paste it in vim by right clicking the mouse in insert mode. IF i highlight text in the terminal ( wich copys it to clip) and type "+p in Vim i get nothing. If i tyoe :reg i dont see the copied text in any register... but i can paste it by right clicking the mouse. Any help would be appreciated!

  • @tdcode
    @tdcode หลายเดือนก่อน

    awesome video.💪💪💪💪

  • @msatul1305
    @msatul1305 2 หลายเดือนก่อน

    Thanks a ton

  • @yoshi314
    @yoshi314 6 ปีที่แล้ว +4

    it seems that on gentoo vim has the ability by default, if you build it with USE="X", which is likely what 90% of people do.

    • @ProtoForte
      @ProtoForte 6 ปีที่แล้ว +1

      Yeah, and after some googling I found the command:
      vim --version | grep clipboard
      which after you run you need to search for "+clipboard" or "+xterm_clipboard", if you have those you can copy and paste to and from the clipboard.
      vim.wikia.com/wiki/Accessing_the_system_clipboard
      is what I found after half a minute of searching.

  • @RobertCastilloC
    @RobertCastilloC 2 ปีที่แล้ว

    You are the best

  • @anonymousperson45152
    @anonymousperson45152 ปีที่แล้ว

    pretty useful

  • @sniperskullz
    @sniperskullz 3 ปีที่แล้ว

    unexpected Sabaton :)

  • @Ricardo-ll3jg
    @Ricardo-ll3jg 3 ปีที่แล้ว

    Thank you Luke, ngl tho you scared me when you opened gvim

  • @Little-bird-told-me
    @Little-bird-told-me ปีที่แล้ว

    god Bless you

  • @agir4707
    @agir4707 3 ปีที่แล้ว

    Thanks!

  • @jeffersonximenes555
    @jeffersonximenes555 ปีที่แล้ว

    thank you

  • @X1Zeth2X
    @X1Zeth2X 6 ปีที่แล้ว

    I just got an X220 with Arch, I'm getting closer. My desktop has Gentoo :3

  • @Klblaz
    @Klblaz 5 ปีที่แล้ว

    I didn't know gvim has the clipboard build in. I remember compiling vim from scratch to get clipboard working.

    • @ThreelionsSFIV
      @ThreelionsSFIV 3 ปีที่แล้ว

      gVim has full X11 working, change fonts on the fly, gtk/gtk3/motif/athena, full mouse x11, more colors, more keys supports that does not depend from terminals like alt/meta, some extra things and of course clipboard too.

    • @Klblaz
      @Klblaz 3 ปีที่แล้ว

      @@ThreelionsSFIV I know that now, I use gvim for pretty much everything, it's much better than TUI vim.

  • @chillshobe8147
    @chillshobe8147 4 ปีที่แล้ว

    You can also use neovim, which is always compiled with the huge option, giving you all the features of vim, and also has saner defaults.

  • @deric916
    @deric916 6 ปีที่แล้ว +4

    Hahahaha "it's as simple as that"

  • @sdnnvs
    @sdnnvs 3 ปีที่แล้ว

    Is there any clipboard manager type app for Vim? When copying multiple text fragments, is there any way to check which register (a, b, c, d etc) should be pasted?

  • @toby.2a
    @toby.2a 5 ปีที่แล้ว

    Hey Luke, love the videos. Why do you have your line numbers set up this way? I don't understand why you might want to know what's 2 lines above or below rather than just viewing line numbers normally. Thanks for the content.

    • @sflux4593
      @sflux4593 3 ปีที่แล้ว

      Why not just g? If you know the line number say 100, you can easily go to it by typing "100g"

  • @jobdedo
    @jobdedo 3 หลายเดือนก่อน

    Thanks dude save d alot of time

  • @slajmlord3211
    @slajmlord3211 4 ปีที่แล้ว

    To move the cursor after the paste, I would suggest gp rather than capital p.

  • @snipzmattio5887
    @snipzmattio5887 3 ปีที่แล้ว

    Thanks

  • @hakety93
    @hakety93 5 ปีที่แล้ว

    Hi Luke. Thanks for another great video.
    I am having issues with the + register being wiped as I exit Vim.
    I tried "autocmd VimLeave * call system("xsel -ib", getreg('+'))", which should pass the buffer as vim quits, but it doesn't seem to work. Any thoughts on what's going on? I should mention that I am running Ubuntu with X11 I3

  • @Argletrough
    @Argletrough 3 ปีที่แล้ว

    NeoVim now allows you to do things the best possible way: Using the system clipboard as the unnamed register:
    set clipboard+=unnamedplus
    This behaviour seems quite invasive, but I'll use it for a while and see if I like it.

    • @markcuello5
      @markcuello5 2 ปีที่แล้ว

      Wow; `NeoVim`. Never heard of it. Is it a `Wiki`?

    • @Argletrough
      @Argletrough 2 ปีที่แล้ว

      @@markcuello5 It's a fork of Vim that mainly served to make Vim development more active through artificial market competition.
      The two are mostly the same, but NeoVim is slightly better.

  • @TheHelvetican
    @TheHelvetican 4 ปีที่แล้ว

    When running vim on an external server, will the "+y command copy to the local or the server clipboard? I haven't tried it yet, but my intuition yes me it will use the server clipboard, so it still couldn't be used to paste into my local Firefox. To get around this, I have simply enabled ctl-c and ctl-v in my Terminator preferences. It isn't minimal but I haven't had any issues. I can simply highlight anything on the terminal with the mouse and copy and paste like normal.

  • @jerodburnett3680
    @jerodburnett3680 6 ปีที่แล้ว +4

    Would you consider a video on regular expressions and implementing them in bash scripts? Whenever I'm actually scripting I seem to go brain dead

    • @conceptrat
      @conceptrat 4 ปีที่แล้ว

      That's what happens when you Bash your Head with a |, Fsck 😀

    • @waseemahmed2567
      @waseemahmed2567 3 ปีที่แล้ว

      watch data wrangling missing semesters

  • @ProtoForte
    @ProtoForte 6 ปีที่แล้ว

    Hahahaha can't believe this video popped up right now, I needed to send a mate some text yesterday out of a file and I didn't know how so I uploaded the entire file to some sketchy website so he could download it.

  • @ThomasCKFuller
    @ThomasCKFuller 6 ปีที่แล้ว +1

    i'm pretty sure if you map control+v to 'paste' you will lose the ability to use "---visual block----" mode not sure tho maybe im just a noob

  • @adityasinghai4365
    @adityasinghai4365 6 ปีที่แล้ว

    thanks

  • @alkeryn1700
    @alkeryn1700 6 ปีที่แล้ว

    i CTRL ^ V
    or "+vimcomand
    Also i use neovim
    which have it by default ^

  • @TechnoBoomer
    @TechnoBoomer 5 ปีที่แล้ว

    Hello Luke. Thanks for this video but the trick does not seem to work on my machine (Fedora 30 + vim 8.1.1359)...

  • @ezeth8576
    @ezeth8576 6 ปีที่แล้ว

    When I use 'vim' straight from terminal. I have almost all the features including copy and pasting to and fro vim and other programs.
    But it doesn't work when I get into vim from 'ranger'. Can someone help?