的PackageControl一些網站的搜索似乎並沒有露面任何看起來像它會做到這一點,但你可以用一些簡單的Python代碼滾你自己。
下面是一個例子插件(適用於崇高文本2和3),它實現一個命令,將這樣做。要使用此,選擇Tools > New Plugin...
或Tools > Developer > New Plugin...
(取決於您使用的崇高文字的版本),並在此替換代碼中的默認插件,然後將其保存爲Python文件。
import sublime, sublime_plugin
import random
class JumpToRandomPositionCommand(sublime_plugin.TextCommand):
"""
When invoked, randomly select a character in the current
file and jump the cursor to that position. Does nothing
if the current file is empty or if the current view does
not represent a file.
"""
def run(self, edit):
view = self.view
if view.size() > 0 and view.settings().get("is_widget", False) == False:
view.sel().clear()
pos = random.randrange(0, view.size())
view.sel().add(sublime.Region(pos, pos))
view.show(pos)
這實現了一個名爲jump_to_random_position
命令,它會隨機選擇該文件中的字符和跳轉光標到那個位置,確保新位置是在屏幕上可見。
這將未選擇任何可能被選中,然後恢復以單一選擇模式(如果不是)。對於空白文件或當前視圖是一個小部件(例如Sublime控制檯中的文本輸入項),它也需要小心。
根據您需要多長時間做這樣的事情,你既可以創建一個鍵的命令綁定:
{
"keys": ["ctrl+alt+shift+r"],
"command": "jump_to_random_position"
}
,或者你可以用下面的代碼手動調用來自崇高的文本控制檯命令(打開控制檯,從菜單中選擇View > Show Console
或按按Ctrl +`:
view.run_command("jump_to_random_position")