简体   繁体   English

如何在Emacs ansi-term中向上滚动

[英]How to scroll up in Emacs ansi-term

I've been Googling around and looking at Emacs built-in help but I have yet to determine how to scroll up (or down) in Emacs ansi-term. 我一直在谷歌上搜索Emacs内置的帮助,但我还没有确定如何在Emacs ansi-term中向上或向下滚动。

I'm using Emacs 23.3.1, OS X, in iTerm2. 我在iTerm2中使用Emacs 23.3.1,OS X. Thanks! 谢谢!

Edit: I've noticed most the advice people give me doesn't work in ansi-term but does work in eshell. 编辑:我注意到大多数人给我的建议在ansi-term中不起作用,但在eshell中起作用。 I have since moved to eshell. 我已经搬到了eshell。

In general, if you don't need full screen terminal emulation, shell or eshell are better choices. 通常,如果您不需要全屏终端仿真, shelleshell是更好的选择。

However, if you decide to stick with ansi-term , press Cc Cj to go into line mode. 但是,如果您决定坚持使用ansi-term ,请按Cc Cj进入行模式。 Then you can move around normally with the usual cursor movement keys. 然后,您可以使用常用的光标移动键正常移动。 Press Cc Ck to get back into char mode to interact with the terminal. Cc Ck返回char模式以与终端进行交互。

Alternatively, you can scroll backwards a screen at a time with Cc Cv and just enter text to scroll back to the terminal input point. 或者,您可以使用Cc Cv一次向后滚动屏幕,然后输入文本以滚动回终端输入点。

Take a look at the Emacs documentation on term-mode (most of which applies equally to ansi-term ) for more information. 有关更多信息,请查看有关term-modeEmacs文档 (其中大部分同样适用于ansi-term )。

Shift-page up/down (in Emacs-speak, S-prior / S-next ) will work using the default bindings. 向上/向下移动页面(在Emacs中, S-prior / S-next )将使用默认绑定。

(While the normal Ch m / Ch b don't work to see mode information and bindings in this mode, you can still use Cc Mx describe-mode / describe-bindings , or depending on your setup, use F1 or the help key instead of Ch .) (虽然正常的Ch m / Ch b在此模式下无法查看模式信息和绑定,但您仍然可以使用Cc Mx describe-mode / describe-bindings ,或者根据您的设置,使用F1帮助键代替Ch 。)

install evil-mode at first, press Cz to switch to vim key binding. 首先安装evil-mode,按Cz切换到vim键绑定。

  • You can use Cf , Cb to scroll up and down 您可以使用CfCb向上和向下滚动
  • you can use 20% to jump to to the top 20% of the buffer 您可以使用20%跳转到缓冲区的前20%
  • you can use / , ? 你可以用/ , ? , # , * to search the text in the buffer. #*来搜索缓冲区中的文本。
  • all the grep/filter commands now usable (occur, swiper, helm-swoop, .... just name a few) 所有grep / filter命令现在都可用(发生,swiper,helm-swoop,....仅举几例)
  • you can narrow/widen the buffer 你可以缩小/扩大缓冲区
  • you can yank text 你可以抽出文字

您是否尝试过:向上翻页,向上箭头,Ctrl-V,Alt-V

I was having the same issue but with multi-term (zsh), and after reading the response from @muffinista (the Cv did not work for me) but the Alt-v worked to go 1 page, after that you can use the normal Cp and Cn to scroll up and down. 我有同样的问题,但有多个术语(zsh),并且在阅读@muffinista的回复后( Cv对我不起作用)但是Alt-v工作了1页,之后你可以使用正常CpCn向上和向下滚动。

This worked for me, but it depends a lot on which term you are using and key bindings you might have. 这对我有用,但这在很大程度上取决于您使用的术语和可能具有的键绑定。

For ansi-term, I have this in my .emacs : 对于ansi-term,我在我的.emacs有这个:

(add-hook 'term-mode-hook
          (function
           (lambda ()
             (define-key term-raw-map [?\C-c prior] 'scroll-down)
             (define-key term-raw-map [?\C-c next] 'scroll-up))))

Then I can use Cc pgup and Cc pgdn to scroll. 然后我可以使用Cc pgupCc pgdn来滚动。

Up and down are Ctrl-P and Ctrl-V. 上下是Ctrl-P和Ctrl-V。 There's a whole long list here 有一个整体的长长的名单在这里

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

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