Currently I use following setting in my .emacs file:
;; single tab for every indent
(add-hook 'python-mode-hook
(lambda ()
(setq indent-tabs-mode t)
(setq python-indent 4)
(setq tab-width 4)))
This works perfectly for any new file that I create. By if I download a project from git/hg which happened to be on space emacs will not convert them to be on space. How can I force emacs to convert all the spaces to tabs regardless whats the original setting of the file is.
I understand that this would create large chunk of change set if its a git/hg repo but I still like to figure out how to convert any file with space to change it to tabs via my emacs settings.
Mark the entire buffer with C-x h, and then use M-x tabify
.
Built upon triplee's comment:
(add-hook 'python-mode-hook
(lambda ()
(setq indent-tabs-mode t)
(setq python-indent 4)
(setq tab-width 4))
(tabify (point-min) (point-max)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With