I use iterm in Mac as my command line terminal. In iterm I use tmux as the terminal manager. When I open my code files in Vim copying has become painful in this. To copy text in vim I need to hold "option" key and then select the text. When holding option there are multiple issues: 1) I am unable to scroll while in select mode 2) When I split my terminal into 2 panes, select using option copies across panes making it tough.
I am not sure about the reason for this issue and where to find a workaround. Could anyone help me with it?
You cannot depend on iTerm's clipboard support because it will not know anything about Vim's or tmux's splits. Use native Vim copy instead.
:help v
:help V
:help y
:help d
:help "*
:help clipboard
So e.g. in order to copy two lines, you can do "*2yy
(to clipboard register, two line yank); or you can mark something using visual mode, then just "*y
(to clipboard register, yank). If you want the clipboard register to be always automatically used unless another register is specified, you can add the following to your .vimrc
:
set clipboard+=unnamed
Then a simple 2yy
will copy two lines, and you can just paste it in iTerm or any other application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With