emacs - 禁止 emacs 将制表符转换为空格
问题描述
我最近开始使用 Emacs,遇到的一个问题是编辑器会自动将所有制表符转换为空格。现在开始有点烦了。
这是我的.emacs
文件供参考:
(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(proto (if no-ssl "http" "https")))
(when no-ssl
(warn "\
Your version of Emacs does not support SSL connections,
which is unsafe because it allows man-in-the-middle attacks.
There are two things you can do about this warning:
1. Install an Emacs version that does support SSL and be safe.
2. Remove this warning from your init file so you won't see it again."))
;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
(add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
(when (< emacs-major-version 24)
(add-to-list 'package-archives (cons "gnu" (concat proto "://elpa.gnu.org/packages/")))))
(package-initialize)
(custom-set-variables
'(custom-enabled-themes (quote (dracula)))
'(custom-safe-themes)
'(display-line-numbers-type (quote relative))
'(global-display-line-numbers-mode t)
'(menu-bar-mode nil)
'(package-selected-packages
(quote
(company-irony-c-headers company-irony micgoline elpy company-jedi molokai-theme gruvbox-theme autopair auto-complete anaconda-mode nyan-mode dracula-theme company)))
'(scroll-bar-mode nil)
'(tool-bar-mode nil))
(custom-set-faces
)
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq inhibit-startup-message t) ;; hide the startup message
(elpy-enable)
(pyenv-mode)
(setq python-shell-interpreter "ipython"
python-shell-interpreter-args "-i --simple-prompt")
(require 'powerline)
有关如何阻止 emacs 执行此行为的任何建议?
解决方案
正如 Drew 所建议的,我将其发布为答案:
你检查变量了indent-tabs-mode
吗?
有了这个,您应该能够使用空格或制表符在 emacs 之间切换。
正如这里的 emacs wiki 中所述,我假设,某些活动模式在您的 emacs 中将其设置为 nil。您可以在此处找到另一种解释,其中包含有关选项卡是否邪恶的讨论链接
编辑:奇怪的是,python-mode 设置indent-tabs-mode
为 t。也许这个 Emacs Wiki条目可以解决您的问题。来自维基的这个片段:
(add-hook 'python-mode-hook
(lambda ()
(setq-default indent-tabs-mode t)
(setq-default tab-width 4)
(setq-default py-indent-tabs-mode t)
(add-to-list 'write-file-functions 'delete-trailing-whitespace)))
看起来它会成功的。希望这可以帮助。
推荐阅读
- django - Django:模板上重新组合的项目的总和
- flutter - 颤振通知图标在Android中没有改变
- electron - 通过requirejs导入电子
- google-apps-script - 有没有办法在 Google 表格中创建脚本来打印 2 份活动工作表?
- python - Python 如何从打印结果中删除前导回车?
- javascript - JavaScript 前导零数字填充
- reactjs - 在两个组件之间使用 Cookie
- android - 科尔多瓦上的导航栏颜色没有改变
- firebase - 未捕获的错误:预期类型为“FutureOr”的值
',但得到了“MemoryInfo”类型之一 - php - 如何创建两个 laravel 项目(在同一台服务器上),共享除资源(视图)文件夹之外的所有文件