Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using Emacs for Python developement. My team is using Tab indentation, so I must do the same. The problem is that I can't figure out how to make python-mode use tabs instead of spaces. I want Emacs to automatically indent my line to the correct level when I press Ctrl-j.

share|improve this question
up vote 2 down vote accepted

You'll want to add the following to your .emacs file:

(add-hook 'python-mode-hook
  (lambda () (setq indent-tabs-mode t))
share|improve this answer
It worked! Thanks! – Cristi Mocanu Mar 18 '13 at 20:36
I'm a spoiled vim user, so I really don't know. What does the '-character do/mean? I find it rather odd to see an odd number of those in one statement ... – Bananguin Mar 18 '13 at 20:55
@user1129682 quotation, see gnu.org/software/emacs/manual/html_node/elisp/Quoting.html – Ulrich Dangel Mar 18 '13 at 21:04
@user1129682, emacs is mostly written in LISP, and the above is a LISP statement adding a function to python-mode-hook, a list of functions to run when starting to edit Python code. What the apostrophe does is to tell LISP that python-mode-hook is the variable to modify, not its name. – vonbrand Mar 19 '13 at 17:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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