Searching for marked (selected) text in Emacs

后端 未结 8 538
北恋
北恋 2021-01-31 01:50

I use emacs for viewing and editing code and other text files. I wanted to know if there is a way to search forward or backward for text which is marked in the current buffer. S

8条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-31 02:25

    There is a great function for this: isearch-forward-symbol-at-point. It highlights all occurrences of the word where your point is located - no need to place the point at the beginning of the word. Then you can move to next or previous with C-s or C-r.

    Note that it is an exact match: if you use it on hi it won't match chill for instance.

    I mapped if to command-f (mac OSX): (global-set-key (kbd "s-f") 'isearch-forward-symbol-at-point) in the init file.

提交回复
热议问题