Emacs,使用Delete键删除选择 [英] Emacs, use Delete key to delete selection

查看:1100
本文介绍了Emacs,使用Delete键删除选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,这不是一个重复的




  • 如何使用emacs中的[delete]键删除区域,这是Emacs 23,答案是Emacs cua-mode

  • 如何配置delete-selection-mode只能删除?,这是Emacs 22,而且这个问题是不可重复的。我正在谈论 Emacs删除选择模式,我以前只需按删除键即可删除文本选择。我发现我的证明 here


    为了在按DEL,Ctrl-d或Backspace时设置emacs删除所选文本,请将以下内容添加到.emacs文件中: p>



     (delete-selection-mode t)
    / pre>

    然而,现在,使用我的Emacs 24,删除键不再适用于选择(只有 Backspace 确实)。这真的很烦人,因为我使用的所有编辑器,按删除键将删除文本选择。我不明白为什么Emacs必须如此不同和不方便。无论如何,



    任何简单的方法来解决它?我不知道以下内容的评论是一个笑话或实际的解决方案:

     (setq behave-like-something-actual-useful-by-humans t)

    谢谢



    PS,我的Emacs 24是从夜间构建:

      $ emacs --version |头-1 
    GNU Emacs 24.3.50.1

    编辑:来自德鲁的答案,如果不清楚(我第三次尝试),

     (全局设置键(使用区域-p)(删除区域(区域开始)(区域结束))(删除字符串)(lambda(n)(交互式p) ))))

    适用于我。

    解决方案

    默认情况下,< delete> code>杀线。听起来你想要绑定到 delete-region

     (global-set-key(kbd< delete>)'delete-region)


    First of all, this is not a dup of

    I'm talking about the Emacs Delete Selection Mode, I used to be able to delete selection of text by just pressing Delete key. I found my proof here.

    In order to set emacs to delete the selected text when you press DEL, Ctrl-d, or Backspace, add the following to your .emacs file:

    (delete-selection-mode t)
    

    However, now, with my Emacs 24, the Delete key doesn't work on the selection anymore (only Backspace does). This is really annoying because for all editors that I use, pressing the Delete key will delete the text selection. I don't understand why Emacs has to be so different and inconvenient. Anyway,

    Any easy way to fix it? I don't know whether the comment of the following was a joke or the actual solution:

    (setq behave-like-something-actually-usable-by-humans t)
    

    Thanks

    PS, my Emacs 24 is from nightly build:

    $ emacs --version | head -1 
    GNU Emacs 24.3.50.1
    

    EDIT: The answer from Drew, if it is unclear to you (I got that on third attempt),

    (global-set-key (kbd "<delete>") '(lambda (n) (interactive "p") (if (use-region-p) (delete-region (region-beginning) (region-end)) (delete-char n))))
    

    works for me.

    解决方案

    The <delete> key is bound by default to kill-line. It sounds like you want to bind it instead to delete-region. Just do it.

    (global-set-key (kbd "<delete>") 'delete-region)
    

    这篇关于Emacs,使用Delete键删除选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆