macos 在 Mac 终端的 Vim 中滚动

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1727261/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 06:32:16  来源:igfitidea点击:

Scrolling inside Vim in Mac's Terminal

macosvimterminal

提问by hora

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

我一直在谷歌搜索,试图弄清楚是否可以在 Mac 终端的Vim中使用鼠标滚轮滚动,但没有运气。似乎只有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?

还是我应该认真考虑使用不同的终端应用程序?

采纳答案by Jonatan Littke

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 后再次启动它。

回答by Shane Reustle

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

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

:set mouse=a

回答by mmacvicar

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+Ror Menu View --> Allow Mouse Reporting. Turning that on allowed the mouse/trackpad scroll operations to move the cursor in vim.

默认情况下,在 Terminal.app 中运行 OSX El Capitan 10.11、vim 鼠标和触控板滚动对我来说刚刚工作(TM)。然而,鼠标/触控板输入偶尔会停止操作 vim 缓冲区,并开始滚动终端缓冲区。答案是Command+R或菜单视图 --> 允许鼠标报告。打开它允许鼠标/触控板滚动操作在 vim 中移动光标。

回答by Afagh

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

回答by Topher Fangio

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.

您可以阅读这篇文章,但我很确定,因为 Mac OS X 中的默认终端有一个内置滚动条,鼠标滚轮命令会自动转到它。您绝对可以按照上一个答案中的建议使用 gVim。我发现我通常不想在 Vim 中使用鼠标,因为它会将我的手从键盘上移开。

I just use 50jto go down and 50kto go up. Not exactly scrolling, but it works pretty well.

我只是50j习惯了下降和50k上升。不完全滚动,但效果很好。

回答by apochev

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

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

set ttymouse=xterm2

回答by XPac27

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

回答by robince

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

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

回答by Greg Hewgill

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

使用 gVim,它在可以滚动的窗口中为您提供文本编辑环境。使用 gVim 时不涉及终端。

回答by dayne

Make sure the terminal is xterm& not ansiin 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.

确保终端是xterm与不是ansiTerminal Menu > Preferences > Profiles > Advanced。我无意中通过更改术语类型来使着色在 ssh 上工作,从而不小心破坏了滚动。