I'm trying to comment a region of code in my init.el file, so I type M-x comment-region

While I see the match I want in Emacs Commands Helm actually autocompletes this to uncomment-region since this is in my Emacs Commands History.

When I hit /enter/ it replaces my comment-region command with an uncomment-region command, with the result that I am unable to execute comment-region at all. I cannot navigate the commands in the lower buffer---I can only see it identifies and does not use the comment function.

What am I doing wrong and how can I prevent Helm from auto-incorrecting the command I am trying to execute with [Enter] here?


2 Answers 2


The problem "can't navigate the buffer" is most likely caused by that you have helm-move-to-line-cycle-in-source set to t - it makes the cursor stay in the history section. I don't know why would anyone want it, so reset the variable to nil.


These are the ways I can think of to do it:

  1. Start the command with ^ like this: ^comment-region. This will select commands that begin with that substring, automatically selecting comment-region.
  2. Customize variable helm-M-x-reverse-history to t. This will switch the order of sections Emacs Commands history and Emacs Commands, so that comment-region will be selected first.
  3. Use down arrow (or C-n) to select comment-region and press Enter. (I see that you mention that you can't navigate the buffer, but I don't see a reason why it shouldn't work in a standard Helm installation.)
  4. If you follow #3, the next time you type comment-region, it will be automatically selected since it will be present in the history. No need to follow #1 or #2.

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.