I always had trouble finding a way to copy lines of code in vim when I wanted to paste the lines in some other application on macOS. You see vim doesn’t use the OS clipboard when it copies something.
I finally found a way:
echo "vmap '' :w !pbcopy<CR><CR>" >> ~/.vimrc
Now, whenever you select visual mode using :v
, select some text, and press ''
the text will be copied to the macOS clipboard.
It may not be the best solution as it depends on having pbcopy
installed on your system, and it does a weird flicker, but it works!
Now, you may ask why I am using vim? That’s another question, maybe for another post. 😀