[英]emacs: Convert python spaces to tabs
Currently I use following setting in my .emacs file: 目前,我在.emacs文件中使用以下设置:
;; 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.
如果我从git / hg下载一个项目,而该项目恰好在太空中,那么emacs不会将它们转换为在太空中。 How can I force emacs to convert all the spaces to tabs regardless whats the original setting of the file is.
无论文件的原始设置是什么,如何强制emacs将所有空格都转换为制表符。
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. 我知道,如果它是git / hg回购,这会创建大量更改集,但我仍然想弄清楚如何转换任何带有空间的文件,以通过我的emacs设置将其更改为选项卡。
用Cx h标记整个缓冲区,然后使用Mx 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)))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.