English 中文(简体)
缩略语:在点上插入一字以代替方格
原标题:Emacs: Insert word at point into replace string query
  • 时间:2011-11-24 12:25:12
  •  标签:
  • emacs

在<代码>C-s之后插入“密码>C-w,但替换(和替换“regexp”)查询时,是否有一个类比?

我也享受Sacha Chua对C-x的修改,在研究中插入整个字句:

http://sachua.com/blog/2008/07/emacs-key板-shortcuts-for-navigating-code/

在某些情况下,如果可以用来取代扼杀,这也会真正有用。

I d be very thankful for any tips! Thank you!

最佳回答

这样做是可能的,尽管在研究中它作为“C-w的ancy,因为你可以随时打上扩大甄选的关键:

(defun my-minibuffer-insert-word-at-point ()
  "Get word at point in original buffer and insert it to minibuffer."
  (interactive)
  (let (word beg)
    (with-current-buffer (window-buffer (minibuffer-selected-window))
      (save-excursion
        (skip-syntax-backward "w_")
        (setq beg (point))
        (skip-syntax-forward "w_")
        (setq word (buffer-substring-no-properties beg (point)))))
    (when word
      (insert word))))

(defun my-minibuffer-setup-hook ()
  (local-set-key (kbd "C-w")  my-minibuffer-insert-word-at-point))

(add-hook  minibuffer-setup-hook  my-minibuffer-setup-hook)

EDIT: Note that this is in the standard minibuffer, so you can use it use it anywhere you have a minibuffer prompt, for example in grep, occur, etc.

问题回答

两个答案:

  1. Replace+在你援引指令时自动取到作为违约值的案文。

  2. More generally, Icicles does something similar to what scottfrazer s code (above) does, but it is more general. At any time, in any minibuffer, you can hit M-. (by default) to pick up text ("things") at point and insert it in the minibuffer. You can repeat this, to either (a) pick up successive things (e.g. words) of the same kind, accumulating them like C-w does for Isearch, or (b) pick up alternative, different things at point. More explanation here.

我认为,Emacs已经存在——你刚刚开始用M-S-%,然后用新闻M-n(虽然小楼是空的),但是在曲线下填写的字句子中,可以做些比较有用的事情:





相关问题
suppress additional braces in emacs electric mode

I started using ruby-electric-mode. I like it except that I am used to closing open brackets myself (the other pairing are still useful to me). How can I make emacs suppress additional brackets when ...

Setting up an emacs environment in windows?

I am currently constrained to a windows dev box and I want to migrate my projects from eclipse to emacs. What are some good references on setting up an emacs dev environment for windows? Anything ...

Emacs Setting which-function-mode

I would like to have which-function-mode on by default when I open up Emacs. I ve added the following lines to my .emacs file. (setq which-func-mode t) (setq which-function-mode t) When I open ...

Enabling go mode for emacs

I don t seem to be able to enable a go mode for emacs. C mode doesn t work without semicolons. The best I have found is the JavaScript mode by Karl Landstrom, since JavaScript also doesn t require ...

Custom Emacs key bindings are not working

The key bindings I ve defined in my .emacs file aren t working. Here s the file: ;init modes (menu-bar-mode 0) (tool-bar-mode 0) (cua-mode) (column-number-mode) (fset perl-mode cperl-mode) (cperl-...

eval during emacs lisp macro expansion

How can I fix the simple macro foo in (elisp)Eval During Expansion? None of the followings work: (defmacro foo1 (a) `(setq (eval ,a) t)) (defmacro foo2 (a) `(setq ,(eval a) t)) (defmacro foo3 (...

Get local cvs comment history when committing file/s in emacs

I often commit files with similar cvs comment but not in a single operation. I would like to able to bring up previous comments I ve used in a previous commit when I am in the process of writing a ...

热门标签