emacs 怎么控制光标

2019-02-09 12:49:39 +08:00
 frylkrttj

在高亮括号下,我从 “{ ” 开始滚动屏幕想浏览至 “}”,然而光标却跟着翻页跑了,“}”还没找到“{ ”位置也跟丢了,这种情况大神是怎么解决的。

4341 次点击
所在节点    Emacs
17 条回复
wd
2019-02-10 07:55:19 +08:00
我记得有一个按照括号移动的快捷键的 ctrl-alt-p/f 是不是看看
pimin
2019-02-10 08:14:28 +08:00
亲,我们这里建议您百度一下呢
frylkrttj
2019-02-10 10:03:36 +08:00
@pimin 你还不如不回答
frylkrttj
2019-02-10 10:05:16 +08:00
@wd 不按括号移动呐,我要从 { 慢慢浏览到 } 呢,吃个饭离开会回来还想接着呢
wd
2019-02-10 12:15:57 +08:00
@frylkrttj #4 这个似乎没办法达成。往下移动的时候,光标会尽量保持同列,但是如果你的括号不在一列上 那是没有办法的。据我经验,应该没有哪个编辑器会按你说的做吧?
frylkrttj
2019-02-10 12:33:03 +08:00
@wd 搜过一些教程提到 emacs 下有多光标的实现,但觉得太复杂,想找个简单的
wd
2019-02-10 12:44:58 +08:00
不懂你这个需求。如果编辑器做成这样,那不是有人会觉得光标老自动跳吗?往下移动的时候会自动跳到括号那
frylkrttj
2019-02-10 12:49:33 +08:00
@wd 我的意思现在的滚动的时候光标会跟着跑,怎么让它不跑。#7 的回复看上去是误解我的需求了
wd
2019-02-10 14:16:37 +08:00
@frylkrttj #8 你的意思是光标即使看不见也需要停在原地是么?
frylkrttj
2019-02-10 14:43:32 +08:00
@wd 是啦
wd
2019-02-10 15:43:28 +08:00
@frylkrttj #10 「 Emacs: scroll buffer not point - Stack Overflow 」 https://stackoverflow.com/questions/8993183/emacs-scroll-buffer-not-point 这个试过吗。
frylkrttj
2019-02-10 16:07:18 +08:00
@wd 看不懂这个怎么办
frylkrttj
2019-02-10 16:10:43 +08:00
@wd 上面好像说的是 可以用绑定键来滚动缓冲区域,从而光标不跟着跑?如果没理解错,那我就是看不懂那些绑定的键是怎么做的
wd
2019-02-10 16:26:17 +08:00
你多按几次 Ctrl-u 1 Alt-v
frylkrttj
2019-02-11 10:13:50 +08:00
@wd 没按出我要得结果
wd
2019-02-11 10:15:23 +08:00
https://www.gnu.org/software/emacs/manual/html_node/emacs/Scrolling.html

Some users like scroll commands to keep point at the same screen position, so that scrolling back to the same screen conveniently returns point to its original position. You can enable this behavior via the variable scroll-preserve-screen-position. If the value is t, Emacs adjusts point to keep the cursor at the same screen position whenever a scroll command moves it off-window, rather than moving it to the topmost or bottommost line. With any other non-nil value, Emacs adjusts point this way even if the scroll command leaves point in the window. This variable affects all the scroll commands documented in this section, as well as scrolling with the mouse wheel (see Mouse Commands); in general, it affects any command that has a non-nil scroll-command property. See Property Lists.

查了一下,可能这个 scroll-preserve-screen-position 对你有用,让你在再次滚动回来的时候,光标位于滚动前的那个位置,我感觉应该满足你的需求。

在你的配置文件里面增加一行 (setq scroll-preserve-screen-position t) 或者 (setq scroll-preserve-screen-position 'always) 这两个据说效果不一样,你都可以试试看。
wisetc
2021-10-31 22:44:58 +08:00
%解决问题,evil mode

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/533554

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX