缩放和标签在emacs [英] Indentation and tabs in emacs

查看:163
本文介绍了缩放和标签在emacs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们公司,我们有人使用Windows,OS-X和Ubuntu编写代码(主要是JavaScript),我主要使用Emacs作为我的文本编辑器。



然而,我对于Emacs来说相当新鲜,我发现整个制表符与空格定制有点混淆。



这是我朋友的 Visual Studio代码的设置文件看起来像

  //将您的设置放在此文件中以覆盖默认设置
{
editor.tabSize:4,
editor.insertSpaces:false,

files.trimTrailingWhitespace:true
}

如何复制相同Emacs的设置?
这是我迄今作为我的〜/ .emacs / init.el 文件的一部分,但仍然无法按预期方式工作。 p>

  ;; Tab和空格
(setq-default indent-tabs-mode nil)
(setq default-标签宽度4)

任何帮助来解决这个和/或正确的链接以了解更多将不胜感激

解决方案

你的conf(也许粘贴pb)有一个错误

  ;; Tab和空格
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4);;不是(setq default-tab-width 4)

此配置很好,但有时候另一个配置模式或次模式配置)可以覆盖您的默认值。



例如




  • python使用 python-indent-offset python-indent (自24.3以来已经过时)。

  • C ++使用 c-indent级别

  • nxml使用 nxml-child-indent nxml-attribute-indent

  • ...



所以解决方案取决于语言。你需要一个正确的语言配置。



我希望这有助于


In our company, we have people who use Windows,OS-X and Ubuntu for writing code (mainly javascript) and I use mainly Emacs as my text editor.

However, I am quite new to Emacs, and I find the whole tab vs spaces customisation a bit confusing.

This is what the settings files for my friend's Visual Studio Code looks like

// Place your settings in this file to overwrite the default settings
{
"editor.tabSize": 4,
"editor.insertSpaces": false,

"files.trimTrailingWhitespace": true
}

How do I replicate the same settings on Emacs? This is what I have so far as part of my ~/.emacs/init.el file, but it still doesn't work as expected.

;;Tab and spaces
(setq-default indent-tabs-mode nil)
(setq default-tab-width 4)

Any help to solve this and/or proper links to learn more will be appreciated..

解决方案

There is an error in your conf (maybe paste pb)

;;Tab and spaces
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4) ;; not (setq default-tab-width 4)

This configuration is good but sometime another configuration (major-mode or minor-mode configuration) could overwrite your defaults.

For example

  • python use python-indent-offset or python-indent (obsolete since 24.3).
  • C++ use c-indent-level
  • nxml use nxml-child-indent and nxml-attribute-indent.
  • ...

So the solution depends on the languages. You need a proper configuration by language.

I hope this helps

这篇关于缩放和标签在emacs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆