V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
frylkrttj
V2EX  ›  Emacs

emacs 怎么控制光标

  •  
  •   frylkrttj · 2019-02-09 12:49:39 +08:00 · 4301 次点击
    这是一个创建于 1874 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    17 条回复    2021-10-31 22:44:58 +08:00
    wd
        1
    wd  
       2019-02-10 07:55:19 +08:00 via iPhone
    我记得有一个按照括号移动的快捷键的 ctrl-alt-p/f 是不是看看
    pimin
        2
    pimin  
       2019-02-10 08:14:28 +08:00 via Android
    亲,我们这里建议您百度一下呢
    frylkrttj
        3
    frylkrttj  
    OP
       2019-02-10 10:03:36 +08:00
    @pimin 你还不如不回答
    frylkrttj
        4
    frylkrttj  
    OP
       2019-02-10 10:05:16 +08:00
    @wd 不按括号移动呐,我要从 { 慢慢浏览到 } 呢,吃个饭离开会回来还想接着呢
    wd
        5
    wd  
       2019-02-10 12:15:57 +08:00 via iPhone
    @frylkrttj #4 这个似乎没办法达成。往下移动的时候,光标会尽量保持同列,但是如果你的括号不在一列上 那是没有办法的。据我经验,应该没有哪个编辑器会按你说的做吧?
    frylkrttj
        6
    frylkrttj  
    OP
       2019-02-10 12:33:03 +08:00
    @wd 搜过一些教程提到 emacs 下有多光标的实现,但觉得太复杂,想找个简单的
    wd
        7
    wd  
       2019-02-10 12:44:58 +08:00 via iPhone
    不懂你这个需求。如果编辑器做成这样,那不是有人会觉得光标老自动跳吗?往下移动的时候会自动跳到括号那
    frylkrttj
        8
    frylkrttj  
    OP
       2019-02-10 12:49:33 +08:00
    @wd 我的意思现在的滚动的时候光标会跟着跑,怎么让它不跑。#7 的回复看上去是误解我的需求了
    wd
        9
    wd  
       2019-02-10 14:16:37 +08:00 via iPhone
    @frylkrttj #8 你的意思是光标即使看不见也需要停在原地是么?
    frylkrttj
        10
    frylkrttj  
    OP
       2019-02-10 14:43:32 +08:00
    @wd 是啦
    wd
        11
    wd  
       2019-02-10 15:43:28 +08:00 via iPhone
    @frylkrttj #10 「 Emacs: scroll buffer not point - Stack Overflow 」 https://stackoverflow.com/questions/8993183/emacs-scroll-buffer-not-point 这个试过吗。
    frylkrttj
        12
    frylkrttj  
    OP
       2019-02-10 16:07:18 +08:00
    @wd 看不懂这个怎么办
    frylkrttj
        13
    frylkrttj  
    OP
       2019-02-10 16:10:43 +08:00
    @wd 上面好像说的是 可以用绑定键来滚动缓冲区域,从而光标不跟着跑?如果没理解错,那我就是看不懂那些绑定的键是怎么做的
    wd
        14
    wd  
       2019-02-10 16:26:17 +08:00 via iPhone
    你多按几次 Ctrl-u 1 Alt-v
    frylkrttj
        15
    frylkrttj  
    OP
       2019-02-11 10:13:50 +08:00
    @wd 没按出我要得结果
    wd
        16
    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
        17
    wisetc  
       2021-10-31 22:44:58 +08:00 via iPhone
    %解决问题,evil mode
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1076 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 18:56 · PVG 02:56 · LAX 11:56 · JFK 14:56
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.