tabs - Sublime Text 3,将空格转换为制表符

标签 tabs sublimetext sublimetext3 spaces auto-indent

我知道有很多关于此的帖子,但我无法让它发挥作用。
我使用选项卡进行编码。有没有办法将始终空格转换为制表符? IE。打开和保存文件?有人有想法吗?

//编辑:
我的愿望是自动执行此操作! -> 打开、保存或即时
有谁知道怎么办吗?


我试过this :

import sublime, sublime_plugin, os

class ExpandTabsOnSave(sublime_plugin.EventListener):
  # Run ST's 'expand_tabs' command when saving a file
  def on_pre_save(self, view):
    if view.settings().get('expand_tabs_on_save') == 1:
      view.window().run_command('expand_tabs')

这是我的用户设置:

{
    "auto_complete_selector": "source - comment, meta.tag - punctuation.definition.tag.begin",
    "auto_indent": true,
    "detect_indentation": true,
    "draw_white_space": "all",
    "ensure_newline_at_eof_on_save": true,
    "expand_tabs_on_save": true,
    "font_face": "SourceCodePro-Regular",
    "font_size": 10,
    "format_on_save": true,
    "ignored_packages":
    [
        "Vintage"
    ],
    "indent_to_bracket": true,
    "open_files_in_new_window": false,
    "smart_indent": true,
    "tab_size": 4,
    "translate_tabs_to_spaces": false,
    "trim_automatic_white_space": true,
    "trim_trailing_white_space_on_save": true,
    "use_tab_stops": false,
    "word_wrap": false
}

最佳答案

在 Sublime Text 窗口的右下角,您会看到一个缩进指示器,看起来很像这样:

Indentation options menu

单击它将打开一个菜单,其中包含用于调整缩进首选项的选项,更重要的是,将缩进转换为制表符/空格

enter image description here

查看 -> 缩进下列出了相同的菜单。

关于tabs - Sublime Text 3,将空格转换为制表符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22529265/

相关文章:

android - 将 ViewPager 与不带 actionBar 的选项卡一起使用

python - 显示评估选择的输出 - Sublime Text Python REPL

c++ - SublimeText C++ 防止在生成时运行

sublimetext3 - 安装 Sublime Text 3 Package Control bz2 时出错

android - 自定义原生库的标签

android - 为什么 Tab 主机在 android 中不显示图标?

sublimetext - 通过突出显示并同时右键单击 Sublime Text 来注释掉代码

macos - 程序包控制停止工作

bash - 崇高的构建代码

android - 如何将TabLayout背景设置为透明