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

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!