Can't copy from vim

February 5, 2018

I was having trouble with copying text out of vim. I was on a Mac, using terminal to access a remote debian server via ssh.

Whenever I selected text in the terminal window, the edit/copy menu option was greyed out, and the vim session showed --visual-- at the bottom of the screen.

This is apparently because selecting text with a mouse puts vim into visual mode, and for some reason you can't copy text in this mode.

To solve it, create a .vimrc file in your user's home directory and add the following to it:

set mouse=v

then restart vim.

References

Tags: vim vi copy terminal mac