I want to use an interactive function to do the vim-like gd n in Emacs, search the current word in buffer

gd in vim will select current word(highlighting same words), and n will cycle selecting the current word in current file. I used to use an interactive function(by google and copy), binding to 'M-n' to do this, (or maybe it is a function in some package) but a few days before my .emacs.d directory has lost by fault. The last few days I've been searching for this function again and again and did not get it. Can any one help me with this? By using this function, I can hit M-n just one time, the word under/just-before/just-after point will be selected and point will go to the next occurance of the same word under/just-before/just-after point. thanks a lot!

Thank you all for your answers!

The key thing is here: I should use the same kbd, say it is M-n to select the current word and to cycling all candidates. so if I put point on a word, I just need to hit M-n multiple times to cycling all the same word in buffer.


  • Clarification: are you asking about the function, or how to bind the function to a key?
    – Dan
    Oct 11, 2016 at 16:08

2 Answers 2


Short answer: C-s C-w

Details: in isearch, C-w is bound to isearch-yank-word-or-char which usually puts the current word in the search query. If the point is on a punctuation mark, this char will be searched.

Another option is to use the package smart-scan (maybe it is what you had in your old .emacs) which searches for the current symbol forward (bound to M-n by default) and backwards (M-p by default).

  • smart-scan is exactly the one I used before! Thanks a lot!
    – cmal
    Oct 11, 2016 at 16:10
  • I'll ask the author of smart-scan how to cycle in buffer and how cycle symbol and word, subword
    – cmal
    Oct 11, 2016 at 16:12
  • M-n should cycle through the buffer. And as far as I can tell, symbol means word, unless subword-mode is activated, and then it means subword (isearch behaves the same way).
    – T. Verron
    Oct 11, 2016 at 16:33
  • does M-n go to the beginning of the buffer when it hits the end ? For me it will stop on the last match
    – cmal
    Oct 11, 2016 at 16:40

You can use M-s . bound to isearch-forward-symbol-at-point by default, and then C-s to search forward for that symbol ('word') or C-r to search backwards.

From C-h f isearch-forward-symbol-at-point:

Do incremental search forward for a symbol found near point. Like ordinary incremental search except that the symbol found at point is added to the search string initially as a regexp surrounded by symbol boundary constructs \_< and \_>.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.