https://blog.csdn.net/shiming_liu/article/details/104090252
概述
最近發(fā)現(xiàn)在iterm2 中打開vim ,用鼠標(biāo)選中文字,并用command + c 復(fù)制選中的文字,但粘貼出來是空的。查了一圈終于在iterm2的官方gitlab issue庫里發(fā)現(xiàn)了解決辦法。將Enable mouse reporting這個(gè)設(shè)置去掉即可。
版本信息
操作系統(tǒng) Mac os 10.15.2
iterm2 iterm2 3.3.6 iterm2 3.3.7
vim Vi IMproved 8.1 (2018 May 18, compiled Dec 26 2018 02:33:06)
重現(xiàn)步驟
- 在
iterm2 中使用cat 命令打印文件,然后用鼠標(biāo)選中command + c 可以正常復(fù)制。 - 但是用
vim 打開文件,選中文字用command + c 復(fù)制,卻不能復(fù)制。 - 并且當(dāng)鼠標(biāo)點(diǎn)擊
vim 中的文字后,vim 會(huì)自動(dòng)變?yōu)?code>visual模式。
解決方案
iterm2 > Preferences > Profiles > Terminal > Enable mouse reporting 去掉勾選 
mouse reporting
mouse reporting的作用是在vim編輯時(shí)識(shí)別鼠標(biāo),可以支持鼠標(biāo)滾輪查看文件內(nèi)容(需要在.vimrc中加入設(shè)置支持鼠標(biāo)有效:set mouse=a,用戶在命令行模式輸入:set mouse=v禁用鼠標(biāo) )。關(guān)閉了mouse reporting后就不支持鼠標(biāo)滾輪了。
那要使用鼠標(biāo)滾輪怎么辦?
可在iterm2 > preferences > advance > 搜索mouse > scroll whell down 那里寫\j > scroll whell up那里寫\k ,作用就是發(fā)送j/k鍵到vim實(shí)現(xiàn)滾動(dòng)效果。 
更多信息
Mac自帶的terminal也會(huì)有這個(gè)問題,在View > Allow Mouse Reporting 去掉勾選 即可 
|