0

I have files which are not .py but they are python code. I want to highlight them as if they were python files. How can I do that.

  • 2
    Simplest thing to do is to switch modes using M-x python-mode. That'll set up highlighting, indentation, keybindings, etc. – amitp Mar 2 '18 at 19:07
  • 1
    If the files have a particular file extension or path component that is unique to them, you can add them to ‘auto-mode-alist’ to have them automatically open up on python mode. – InHarmsWay Mar 3 '18 at 11:57
  • they do have extensions like .bzl – A. K. Mar 5 '18 at 22:43
1

If the file extension is .bzl, then you can do this:

(add-to-list 'auto-mode-alist '("\\.bzl\\'" . python-mode))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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