解決vim選中文字不能複製的問題

轉載自本人獨立博客:https://liushiming.cn/2020/01/18/vim-copy-issue-in-iterm2/git

概述

最近發如今iterm2中打開vim,用鼠標選中文字,並用command + c複製選中的文字,但粘貼出來是空的。查了一圈終於在iterm2的官方gitlab issue庫裏發現瞭解決辦法。將Enable mouse reporting這個設置去掉便可。vim

版本信息

操做系統
Mac os 10.15.2gitlab

iterm2
iterm2 3.3.6
iterm2 3.3.7操作系統

vim
Vi IMproved 8.1 (2018 May 18, compiled Dec 26 2018 02:33:06)code

重現步驟

  1. iterm2中使用cat命令打印文件,而後用鼠標選中command + c能夠正常複製。
  2. 可是用vim打開文件,選中文字用command + c複製,卻不能複製。
  3. 而且當鼠標點擊vim中的文字後,vim會自動變爲visual模式。

解決方案

iterm2 > Preferences > Profiles > Terminal > Enable mouse reporting 去掉勾選
terminal

mouse reporting

mouse reporting的做用是在vim編輯時識別鼠標,能夠支持鼠標滾輪查看文件內容(須要在.vimrc中加入設置支持鼠標set mouse=a)。關閉了mouse reporting後就不支持鼠標滾輪了。get

那要使用鼠標滾輪怎麼辦?博客

可在iterm2 > preferences > advance > 搜索mouse > scroll whell down 那裏寫\j > scroll whell up那裏寫\k,做用就是發送j/k鍵到vim實現滾動效果。
it

更多信息

Mac自帶的terminal也會有這個問題,在View > Allow Mouse Reporting 去掉勾選便可
class

相關文章
相關標籤/搜索