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: Rakesh
Author Info:

Rakesh is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X

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