“超级明星”或者在emacs中找到相当于光标的单词 [英] "super star" or find the word under the cursor equivalent in emacs

查看:105
本文介绍了“超级明星”或者在emacs中找到相当于光标的单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个vim用户,最近一直在尝试emacs的乐趣。我发现我从vim到目前为止最缺少的功能是超级明星(通过键入*)功能找到光标下的单词,我还没有在emacs中找到等效项。如果没有内置,我需要添加到我的emacs文件以获得类似的东西?

解决方案

As 指出 paldepind isearch-forward-symbol-at-point Ms 默认情况下)在Vim中相当于 * 。此功能从GNU Emacs 24.4开始可用;如果您的Emacs不同或更旧,请阅读替代品。



通常我只是做( Mb ...) Cs Cw ... Cs 。那就是:


  1. Mb 移到感兴趣的词开始


    • 零或以上


  2. Cs 开始一个I-Search

  3. Cw 以点


    • 一个或多个


  4. Cs 找到下一场比赛

  5. 更多 Cs 找到以后的比赛

  6. RET 退出最近一次比赛的I-search


    • 或一堆 Cg 中止回到原始起始位置


下面是将其集成到I-Search(通过 Cs Cr ;使用 Ch k Cs 获取 isearch 上的信息。



$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
(lambda()
重置电流是
(交互式)
(setq isearch-word t
isearch-string
isearch-message)
(isearch-yank-string(word-at-point))))

它进入I-Search利用其字匹配和区分大小写设置( Cs Mc C - * 将对区分大小写进行搜索点下的单词)。


I'm a vim user and have recently been trying out emacs for fun. I find that the feature I'm missing most so far from vim is the "super star" (find the word under the cursor by typing *) feature, and I have yet to find the equivalent in emacs. If it's not built in, what would I need to add to my emacs file to get something similar?

解决方案

As pointed out by paldepind, isearch-forward-symbol-at-point (M-s., by default) is a close equivalent to * in Vim. This function is available starting in GNU Emacs 24.4; if your Emacs is different or older, read on for alternatives.

Usually I just do (M-b ...) C-s C-w ... C-s. That is:

  1. M-b to move to beginning of word(s) of interest
    • zero or more of these
  2. C-s to start an I-Search
  3. C-w to yank the word(s) starting at point
    • one or more of these
  4. C-s to find the next match
  5. more C-s to find later matches
  6. RET to exit the I-search at the most recent match
    • or a bunch of C-g to abort back to the original starting location

Here is a go at integrating it into I-Search (invoked via C-s and C-r; use C-h k C-s for info on isearch).

(require "thingatpt")
(require "isearch")
(define-key isearch-mode-map (kbd "C-*")
  (lambda ()
    "Reset current isearch to a word-mode search of the word under point."
    (interactive)
    (setq isearch-word t
          isearch-string ""
          isearch-message "")
    (isearch-yank-string (word-at-point))))

Integrating it into I-Search takes advantage of its word matching and case sensitivity settings (C-s M-c C-* would do a case-sensitive search on the word under point).

这篇关于“超级明星”或者在emacs中找到相当于光标的单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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