1. 程式人生 > 其它 >Sublime Text 設定檔案頭模板

Sublime Text 設定檔案頭模板

開啟Sublime Text
ctrl+shift+p 輸入 install packages
輸入 fileheader 下載完成後

設定-->package settings-->File Header-->settings-User
按照需求自己根據settings-Default修改標識

//file or setting or tmpl can ONLY edit in ASCII
{
    "Default": {
        "author":"TRIX",
        "version":"Python 3.9.5",
    }
}

自定義快捷鍵
設定-->package settings-->File Header-->key bindings-Default

[
    {
        "keys": ["ctrl+alt+n"],//new file
        "command": "file_header_new_file",
        "args":{
            "paths": []
        }
    },
    {
        "keys": ["ctrl+alt+a"],//add head
        "command": "file_header_add_header",
        "args":{
            "paths": []
        }
    }
]

修改模檔案頭板
以python.tmpl舉例
開啟 Sublime Text\Data\Packages\FileHeader\template\header\Python.tmpl
按照需求自己修改模板

# -*- coding: utf-8 -*-
# Version: Python 3.9.5
# Author: {{author}}
# Date: {{create_time}}
# Use:
from logging import basicConfig,DEBUG,debug,CRITICAL,disable # Import debugging module
#disable(CRITICAL)# Remove # when the program is completed
basicConfig(level=DEBUG, format='%(levelname)s: %(message)s. [%(lineno)d]%(filename)s <%(asctime)s>',filename='debug.log',filemode='w')# Set debugging mode. Replace print() with debug()

說明:
author, create_time對應 File Header-->settings-User 中的標識
logging模組是一個用於記錄除錯日誌的模組