简体   繁体   English

在 Mac 终端的 Vim 中滚动

[英]Scrolling inside Vim in Mac's Terminal

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.我一直在谷歌搜索,试图弄清楚是否可以在 Mac 终端的Vim内使用鼠标滚轮滚动,但没有运气。 It seems as if only X11 or iTerm support this.似乎只有X11或 iTerm 支持这一点。

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?还是我应该认真考虑使用不同的终端应用程序?

如果您使用的是 iTerm,请将其添加到您的 vimrc

:set mouse=a

http://bitheap.org/mouseterm/ http://biteap.org/mouseterm/

Use MouseTerm (and do make sure to install SIMBL first!) and scrolling will work like a charm, even remote, using Mac Terminal.使用 MouseTerm(并确保首先安装 SIMBL!)并且使用 Mac Terminal 滚动将像魅力一样工作,甚至远程。

You need to fully quit the Terminal application (Command+Q) and then launch it again after installing MouseTerm.您需要完全退出终端应用程序 (Command+Q),然后在安装 MouseTerm 后再次启动它。

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.默认情况下,在 Terminal.app 中运行 OSX El Capitan 10.11、vim 鼠标和触控板滚动对我来说刚刚工作(TM)。 However occasionally the mouse/trackpad input stopped manipulating the vim buffer, and started scrolling the terminal buffer.然而,鼠标/触控板输入偶尔会停止操作 vim 缓冲区,并开始滚动终端缓冲区。 The answer was Command+R or Menu View --> Allow Mouse Reporting.答案是Command+R或菜单视图 --> 允许鼠标报告。 Turning that on allowed the mouse/trackpad scroll operations to move the cursor in vim.打开它允许鼠标/触控板滚动操作在 vim 中移动光标。

  • Termanal Menu > View > Allow Mouse Reporting终端菜单 > 查看 > 允许鼠标报告
  • Terminal Menu > Preferences > Keyboard > Scroll alternate screen终端菜单 > 首选项 > 键盘 > 滚动备用屏幕

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.您可以阅读这篇文章,但我很确定因为 Mac OS X 中的默认终端有一个内置滚动条,鼠标滚轮命令会自动转到它。 You could definitely use gVim as suggested in the previous answer.您绝对可以按照上一个答案中的建议使用 gVim。 I find that I don't generally want to use the mouse in Vim though as it takes my hands off the keyboard.我发现我通常不想在 Vim 中使用鼠标,因为它会将我的手从键盘上移开。

I just use 50j to go down and 50k to go up.我只是使用50j下降和50k上升。 Not exactly scrolling, but it works pretty well.不完全滚动,但效果很好。

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?如果鼠标功能仍然无法正常工作,请查看我在这篇文章中的回答如何让 vim 在 Mac OS X 上像在 Ubuntu 上一样运行? , just add to your .vimrc ,只需添加到您的 .vimrc

set ttymouse=xterm2

Make sure the terminal is xterm & not ansi in Terminal Menu > Preferences > Profiles > Advanced .Terminal Menu > Preferences > Profiles > Advanced确保终端是xterm而不是ansi I accidentally broke scrolling by changing the term type in a naive effort to get coloring to work over ssh.我无意中通过更改术语类型来使着色在 ssh 上工作,从而不小心破坏了滚动。

Use gVim, which gives you a text editing environment in a window you can scroll.使用 gVim,它在可以滚动的窗口中为您提供文本编辑环境。 Terminal is not involved when using gVim.使用 gVim 时不涉及终端。

I'm using xterm in X11 (XQuartz 2.3.4) and vim works very fine with mouse and also suport 256 colors.我在 X11 (XQuartz 2.3.4) 中使用 xterm,vim 与鼠标一起工作得很好,并且支持 256 种颜色。

Here is the ~/.Xresources I use to make my xterm nicer in X11:这是我用来使 X11 中的 xterm 更好的 ~/.Xresources:

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:小提示,要删除 X11 的 xterm 中的铃声,请键入以下命令:

xset b 0

我建议使用 iTerm - 它比终端有很多优势,例如鼠标支持、256 色、合理的复制和粘贴(自动复制、双击单词/url 选择、中键粘贴)...

When using iTerm create a .vimrc file (if not already there) in your home folder and add the line:使用 iTerm 在您的主文件夹中创建一个 .vimrc 文件(如果还没有)并添加以下行:

:set mouse=a

Scrolling down in vim to view a file works after this.在此之后,在 vim 中向下滚动以查看文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM