I am editing a file and I want to set the tab width (more likely the indent width) to 2 and I have come across a command (setq tab-width 2) but when I use M-x (i.e. Alt-x) on my system and I enter (setq tab-width 2) I get the message [No match].

I think the keystroke M-x is the wrong one. I get list of commands to select from, but what I am looking for is the right place to change a setting in Emacs with a Lisp command.

  • 1
    FYI, you can also use the set-variable interactive command: M-x set-variable tab-width ... Jun 14, 2017 at 1:51

1 Answer 1


You are looking for eval-expression, bound by default to M-:.

M-: is different from M-x, which is bound to execute-extended-command. The latter is used specifically for commands (interactive functions that do something). The former is used to evaluate a lisp expression, which is what you're trying to do when you're setting the value of some variable.

You can read more about it in the manual nodes on:

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.