Scrolling inside Vim in Mac's Terminal

后端 未结 11 2057
野性不改
野性不改 2020-12-02 04:46

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

相关标签:
11条回答
  • 2020-12-02 05:11

    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.

    0 讨论(0)
  • 2020-12-02 05:13

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

    :set mouse=a
    
    0 讨论(0)
  • 2020-12-02 05:13

    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
    
    0 讨论(0)
  • 2020-12-02 05:17

    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 the 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.

    0 讨论(0)
  • 2020-12-02 05:20

    Make sure the terminal is xterm & not ansi in Terminal Menu > Preferences > Profiles > Advanced. I accidentally broke scrolling by changing the term type in a naive effort to get coloring to work over ssh.

    0 讨论(0)
  • 2020-12-02 05:24

    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
    
    0 讨论(0)
提交回复
热议问题