在 Sublime text 3 上按需触发尾随白色 space
Trigger trailing white space on demand on Sublime text 3
与 third answer from this question, 相关 我想重构这个简单的插件,以便它可以与 Sublime Text 3 一起使用。你能帮我吗?我是 python 的新手,我对 sublime 的插件开发一无所知。
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()
。我不想安装一个插件来按需触发尾随白色 space。非常感谢,致以最诚挚的问候。
正在研究 ST3。
import sublime, sublime_plugin
class TrimTrailingWhiteSpace2Command(sublime_plugin.TextCommand):
def run(self, edit):
trailing_white_space = self.view.find_all("[\t ]+$")
trailing_white_space.reverse()
for r in trailing_white_space:
self.view.erase(edit, r)
class TrimTrailingWhiteSpace2(sublime_plugin.EventListener):
def run(self, view):
view.run_command("trim_trailing_white_space2")
在 Sublime Text 3 中,您只需为本机 trim 函数映射一个快捷方式。只需添加
{ "keys": ["ctrl+alt+t"], "command": "trim_trailing_white_space" }
到 Preferences
下的键绑定 → Key Bindings - User
。然后可以通过按 ctrl+alt+t.
来执行
与 third answer from this question, 相关 我想重构这个简单的插件,以便它可以与 Sublime Text 3 一起使用。你能帮我吗?我是 python 的新手,我对 sublime 的插件开发一无所知。
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()
。我不想安装一个插件来按需触发尾随白色 space。非常感谢,致以最诚挚的问候。
正在研究 ST3。
import sublime, sublime_plugin
class TrimTrailingWhiteSpace2Command(sublime_plugin.TextCommand):
def run(self, edit):
trailing_white_space = self.view.find_all("[\t ]+$")
trailing_white_space.reverse()
for r in trailing_white_space:
self.view.erase(edit, r)
class TrimTrailingWhiteSpace2(sublime_plugin.EventListener):
def run(self, view):
view.run_command("trim_trailing_white_space2")
在 Sublime Text 3 中,您只需为本机 trim 函数映射一个快捷方式。只需添加
{ "keys": ["ctrl+alt+t"], "command": "trim_trailing_white_space" }
到 Preferences
下的键绑定 → Key Bindings - User
。然后可以通过按 ctrl+alt+t.