英文:
How to turn off ‘tab’ highlighting in go buffers?
问题
我刚开始在Emacs中编写Go程序。我该如何在go-mode缓冲区中关闭制表符高亮?我使用“whitespace”来高亮显示空白字符。顺便说一下,Go是唯一一个我不想要制表符高亮的模式,因为在Go中制表符是标准格式。
谢谢,Pavel。
英文:
I’ve just started writing Go programs in Emacs. How can I turn off tabs highlighting in go-mode buffers? I use «whitespace» for whitespace chars highlighting. Go btw is the only mode where I don’t want tabs highlighted since tabs are standard formatting in Go.
Sincerely, Pavel.
答案1
得分: 1
清楚了,你是在做类似这样的事情:
(require 'whitespace)
(global-whitespace-mode t)
对吗?你可以通过以下方式在 go-mode
中禁用 whitespace-mode
:
(setq whitespace-global-modes '(not go-mode))
在 Emacs Stack Exchange 上有一个相关的问题:链接。
英文:
To be clear, you're doing something like
(require 'whitespace)
(global-whitespace-mode t)
right? You can disable whitespace-mode
for go-mode
with
(setq whitespace-global-modes '(not go-mode))
There is a related question on emacs stack exchange.
答案2
得分: 0
我发现这个配置对我来说效果更好:
(add-hook 'go-mode-hook
(lambda ()
(add-hook 'before-save-hook 'gofmt-before-save)
(setq whitespace-style '(face empty trailing lines-tail))
(setq tab-width 4)
(setq indent-tabs-mode 1)))
这个配置保留了whitespace-mode
,但不会突出显示制表符。它还在保存前运行go fmt
并将制表符宽度设置为4。我正在使用Prelude。
英文:
I found that this
(add-hook 'go-mode-hook
(lambda ()
(add-hook 'before-save-hook 'gofmt-before-save)
(setq whitespace-style '(face empty trailing lines-tail))
(setq tab-width 4)
(setq indent-tabs-mode 1)))
Worked a bit better for me. Leaves whitespace-mode on but doesn't highlight tabs. Also runs go fmt before save and sets tab width to 4. I'm using prelude.
答案3
得分: 0
将以下内容翻译为中文:
将以下行添加到你的go-mode hook中:
(whitespace-toggle-options '(tabs)))
例如:
(use-package go-mode
:preface
(defun go-mode-config ()
(whitespace-toggle-options '(tabs)))
:config
(add-hook 'go-mode-hook (lambda ()
(go-mode-config))))
英文:
Add this line
(whitespace-toggle-options '(tabs)))
To your go-mode hook e.g
(use-package go-mode
:preface
(defun go-mode-config ()
(whitespace-toggle-options '(tabs)))
:config
(add-hook 'go-mode-hook (lambda ()
(go-mode-config))))
Taken from prelue go config
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论