enable copy in iTerm2 using vim with ssh
it’s one thing to copy & paste in the vim when you use it locally, it’s a whole different story to do it in the ssh connected vim, since your host is now another virtual machine whose clipboard is not your clipboard anymore. So, how can we do it?
the most import thing is to disable “Allow Mouse Reporting”
reference regarding iTerm1: https://superuser.com/questions/1815765/how-do-i-copy-text-from-vim-on-a-remote-host-in-terminal-to-local-macos-clipboa in the comment
and to find it in the new iTerm2: see the picture, need to right click on your iTerm2 and go to the Terminal State
menu, there you can find the Mouse Reporting
checkbox
after the disabling of this Mouse Reporting
, you can use the mouse to select the texts in your iTerm2’s vim. (even it’s using ssh connected to another machine, the selection’s color is different than the vim’s visual mode’s selection by default. It’s brighter.) Then you can copy your selection using keyboard or the typical Ctrl+c
command.