如何让 emacs 在 tab 字符上执行与其他编辑器相同的操作?

发布于 2024-10-09 14:24:30 字数 286 浏览 4 评论 0原文

emacs 中的 TAB 键与 indent-for-tab-command 绑定,但缩进本身会将所有制表符转换为空格,我不喜欢这种做法,因为在代码中定位字符比较困难,而且代码会变大。

我尝试使用 (setq-default indent-tabs-mode t)、(setq tab-width 4) 或 (setq default-tab-width 4),以上都不起作用。 \t 字符的宽度不会改变,缩进也不会使用制表符而不是空格。 而且“Mx tabify”也不起作用。

我搜索了很长时间但几乎一无所获。有什么想法吗?

The TAB key in emacs is bound to indent-for-tab-command, but the indent itself converts all the tabs into spaces, which I didn't like because it's harder to locate character in the code and the code gets bigger.

I tried to use (setq-default indent-tabs-mode t), (setq tab-width 4) or (setq default-tab-width 4), none of the above works. Neither the width of \t character changes, nor the indent uses tabs instead of spaces.
And 'M-x tabify' does not work either.

I searched for a long time but got nearly nothing. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

帅的被狗咬 2024-10-16 14:24:30

这是您的 .emacs 设置,如果您的 .emacs 文件中没有任何特殊设置,则应默认插入制表符。

;; This will force emacs to insert spaces instead of tabs
(setq-default indent-tabs-mode t)

这另外两个设置不相关。

检查 emacswiki.org 是否有任何与 Emacs 相关的问题。

It's your .emacs settings, if you don't have any special settings in your .emacs file, tab should be inserted by default.

;; This will force emacs to insert spaces instead of tabs
(setq-default indent-tabs-mode t)

This other two settings are not related.

Check emacswiki.org for any Emacs related questions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文