我知道有很多关于这个的帖子,但我无法让它起作用。
我使用制表符进行编码。是否有一种方法可以始终将空格转换为制表符?即在打开和保存文件时?有人有想法吗?
// 编辑:
我的愿望是以自动的方式实现!->打开、保存或即时转换
有人知道如何做到这一点吗?
我尝试了这个:
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
}
Ctrl + ~
打开控制台并查看是否有任何插件错误?如果你已经安装了Package Control,你能否查看ExpandTabsOnSave
是否被列为已安装的插件? - angersonprint("debug")
或类似的语句,以查看它是否在保存时执行。 - angerson