在 Emacs 中设置制表符大小

发布于 2024-08-26 18:02:19 字数 315 浏览 8 评论 0原文

我使用 Emacs 作为编辑器。我想将制表符大小设置为四个空格。在我的 .emacs 文件中,我有以下内容:

(setq default-tab-width 4)

我也尝试过:

(set-default tab-width 4)

无论哪种方式,当我打开 emacs 并尝试按 Tab 键时,它都会插入两个空格。我做错了什么吗?看起来好像没有看到我的 .emacs 文件。

任何建议都会很棒!谢谢!

I'm using Emacs as an editor. I want to set the tab size to four spaces. In my .emacs file I have the following:

(setq default-tab-width 4)

I've also tried:

(set-default tab-width 4)

Either way, when I open emacs and try to tab, it inserts two spaces. Am I doing something wrong? It almost seems like its not seeing my .emacs file.

Any suggestions would be great! Thanks!

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

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

发布评论

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

评论(2

删除→记忆 2024-09-02 18:02:20

tab-width 变量无法确定每级的缩进量,并且 TAB 键不会插入制表符:它将当前行缩进到正确的缩进量大多数语言模式的水平。

如果您使用 C、C++ 或 Java(以及其他一些基于 cc-mode)进行编程,请尝试将 c-basic-offset 设置为 4。或者点击Cc . 并选择另一种缩进样式;也许有一款适合您的口味。

The tab-width variable doesn't determine the amount of indenting per level, and the TAB key doesn't insert a tab: it indents the current line to the correct indentation level in most language modes.

If you're programming in C, C++ or Java (and a few more, based on cc-mode), try setting c-basic-offset to 4. Or hit C-c . and select another indentation style; there might be one that matches your taste.

戏蝶舞 2024-09-02 18:02:20

tab-width 变量控制制表位,而不是缩进偏移量,如果制表位不匹配,则根据需要用空格填充(假设您将 emacs 设置为插入物理制表符)。

  • 在 bash 模式下,该变量为 sh-basic-offset
  • 在Python模式下,该变量是python-indent-offset
  • 在c模式下,变量是c-basic-offset

如果你知道更多,请评论或编辑这篇文章。

The tab-width variable controls the tab stops, not the indentation offset which is padded with spaces as needed if the tab stop does not match (assuming you have emacs set to insert physical tabs).

  • In bash mode, the variable is sh-basic-offset.
  • In python mode, the variable is python-indent-offset.
  • In c mode, the variable is c-basic-offset.

If you know of any more, please comment or edit this post.

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