與third answer from this question,相關我想重構這個簡單的插件,以便它可以與Sublime Text 3一起使用。請幫助我嗎?我是python的新手,對於崇高的插件開發我一無所知。觸發在崇高文本上追加需求的白色空間3
import sublime, sublime_plugin
def trim_trailing_white_space2(view):
trailing_white_space2 = view.find_all("[\t ]+$")
trailing_white_space2.reverse()
edit = view.begin_edit()
for r in trailing_white_space2:
view.erase(edit, r)
view.end_edit(edit)
class TrimTrailingWhiteSpace2Command(sublime_plugin.TextCommand):
def run(self, edit):
trim_trailing_white_space2(self.view)
我已搜查,問題是begin_edit()
和end_edit()
。我不想安裝插件只是爲了按需觸發尾隨空白。非常感謝,最誠摯的問候。
Sublime有這個內置的,你可以在設置中設置''trim_trailing_white_space_on_save「:true,'。 – Kos 2015-02-24 14:56:55
是的,我知道,但是我在一個團隊中工作的人不會裁剪拖尾的空白區域,所以我只想刪除我自己文件中的空白區域。從快捷方式觸發是完美的。 – 2015-02-24 14:59:53
如果你的項目沒有這個約定,我建議強制執行它,讓每個人都設置他們的編輯器,或者只是忘記它,而不是混淆了「你自己的文件」中無關空格變化的差異。一致性在此獲勝。 – Kos 2015-02-24 15:06:27