首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >禁止emacs将制表符转换为空格

禁止emacs将制表符转换为空格
EN

Stack Overflow用户
提问于 2020-01-29 21:24:44
回答 1查看 390关注 0票数 0

我最近开始使用Emacs,我一直面临的一个问题是编辑器会自动将所有的制表符转换为空格。现在已经开始变得有点烦人了。

下面是我的.emacs文件以供参考:

代码语言:javascript
复制
(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执行此操作,有什么建议吗?

EN

回答 1

Stack Overflow用户

发布于 2020-01-30 00:12:48

根据Drew的建议,我将此作为答案发布:

你检查变量indent-tabs-mode了吗?

这样,您应该能够使用空格或制表符在emacs之间切换。

正如我在emacs wiki here中所描述的,一些活动模式在您的emacs中将其设置为nil。您可以找到另一种解释,其中包含有关选项卡是否是邪恶的here的讨论的链接

编辑:奇怪的是,python模式将indent-tabs-mode设置为t。也许这个Emacs Wiki entry可以解决你的问题。这段来自wiki的代码片段:

代码语言:javascript
复制
(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)))

看起来它能起到作用。希望这能有所帮助。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59968080

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档