How to Copy all text to Clipboard in Vim


If you are looking for ways to copy all text from Vim (vi) editor to your clipboard then you can follow the below steps.

  1. Open the file in the vim (vi) editor.
  2. Now enter visual mode by pressing Shift + v (you will see -- VISUAL -- at the bottom)
  3. Select all the text on the page and press y. You will see a message "x lines yanked".
  4. Note press colon ":" and type %!pbcopy. This will copy the entire text to the clipboard.
vi lines yanked

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap