Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs set spacing for inline (end of line) comments

In the PEP 8 style guide for python, it is recommended that inline comments are separated by the rest of the line by two spaces. However, the default in Emacs is that running comment-dwim or indent-for-comment puts only one space between the end of the line and the comment. Is there a way to change this default behavior in emacs?

I am running Emacs 23.3.1

like image 828
rottweiler Avatar asked Feb 17 '13 20:02

rottweiler


2 Answers

This should do what you want:

   (add-hook 'python-mode-hook
      (lambda () (set (make-local-variable 'comment-inline-offset) 2)))
like image 171
Andrzej Pronobis Avatar answered Oct 05 '22 08:10

Andrzej Pronobis


You can check emacs's documentation by C-h v RET comment-inline-offset, then you will find the answer as @And said.

Here's a simplified version:

(add-hook 'python-mode-hook
  (lambda () (setq-local comment-inline-offset 2)))
like image 24
Xiao Hanyu Avatar answered Oct 05 '22 08:10

Xiao Hanyu