Scrolling inside Vim in Mac's Terminal

心已入冬 提交于 2019-12-17 10:07:56

问题


I've been googling around trying to figure out if it's possible to use my mouse wheel to scroll while inside Vim in Mac's Terminal, with no luck. It seems as if only X11 or iTerm support this.

Before I give up, I thought I'd try the geniuses here to see if anyone knows a way to do this. So, does anyone know if I can set that up?

Or should I seriously consider using a different terminal application?


回答1:


http://bitheap.org/mouseterm/

Use MouseTerm (and do make sure to install SIMBL first!) and scrolling will work like a charm, even remote, using Mac Terminal.

You need to fully quit the Terminal application (Command+Q) and then launch it again after installing MouseTerm.




回答2:


And if you're using iTerm, add this to your vimrc

:set mouse=a



回答3:


This is an old question, but a top hit on google, so I feel compelled to provide an updated answer.

Running OSX El Capitan 10.11, vim mouse and trackpad scrolling just worked(TM) for me in Terminal.app by default. However occasionally I'd get into a situation where mouse/trackpad input stopped manipulating the vim buffer, and started scrolling the terminal buffer. The answer was Command+R or Menu View --> Allow Mouse Reporting. Turning that on allowed the mouse/trackpad scroll operations to move the cursor in vim.




回答4:


You can read this article, but I'm pretty sure since the default terminal in Mac OS X has a built-in scrollbar, the mousewheel commands automatically go to it. You could definitely use gVim as suggested in the previous answer. I find that I don't generally want to use the mouse in Vim though as it takes my hands off the keyboard.

I just use 50j to go down and 50k to go up. Not exactly scrolling, but it works pretty well.




回答5:


  • Termanal Menu > View > Allow Mouse Reporting
  • Terminal Menu > Preferences > Keyboard > Scroll alternate screen



回答6:


If the mouse functionalities still do not work properly take a look at my answer in this post How to let vim behave on Mac OS X as on Ubuntu?, just add to your .vimrc

set ttymouse=xterm2



回答7:


Use gVim, which gives you a text editing environment in a window you can scroll. Terminal is not involved when using gVim.




回答8:


I'm using xterm in X11 (XQuartz 2.3.4) and vim works very fine with mouse and also suport 256 colors.

Here is the ~/.Xresources I use to make my xterm nicer in X11:

XTerm*faceName: Lucida Sans Typewriter Regular
XTerm*faceSize: 9
XTerm*utf8: 1

xterm*saveLines: 1000
xterm*jumpScroll: true
!xterm*awaitInput: true
!xterm*multiScroll: true

XTerm*scrollBar: false
xterm*scrollbar*thickness: 16
xterm*rightScrollBar: true

XTerm*foreground: white
XTerm*background: grey10
!XTerm*background: black
XTerm*cursorColor: yellow

xterm*visualBell: false

xterm*loginShell: true

Little tips, to remove the bell sound in X11's xterm type this command:

xset b 0



回答9:


I would recommend using iTerm - it has so many advantages over Terminal eg Mouse support, 256 colors, sensible copy and paste (auto-copy, word/url selection with double click, middle click paste)...




回答10:


When using iTerm create a .vimrc file (if not already there) in your home folder and add the line:

:set mouse=a

Scrolling down in vim to view a file works after this.



来源:https://stackoverflow.com/questions/1727261/scrolling-inside-vim-in-macs-terminal

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!