我知道有很多关于此的帖子,但我无法让它发挥作用。
我使用选项卡进行编码。有没有办法将始终空格转换为制表符? 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 窗口的右下角,您会看到一个缩进指示器,看起来很像这样:
单击它将打开一个菜单,其中包含用于调整缩进首选项的选项,更重要的是,将缩进转换为制表符/空格
。
查看 -> 缩进
下列出了相同的菜单。
关于tabs - Sublime Text 3,将空格转换为制表符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22529265/