Sublime Text 2/3 - 如何始终在当前行下至少有 10 行?

Sublime Text 2/3 - How to always have at least 10 lines under current line?

有没有办法在 ST 中显示当前行下方至少 x 行?假设我的光标在第 55 行,我希望 Sublime 在当前行下方至少显示 10 行,这样第 55 行永远不会出现在屏幕底部。这在 Sublime 中可行吗?

您可以使用一个简单的插件来实现这一点,该插件侦听光标移动事件。

从 Sublime Text 的 Tools 菜单中,单击 New Plugin。 将内容替换为以下内容:

import sublime, sublime_plugin

class ShowLinesUnderSelectionListener(sublime_plugin.EventListener):
    def show_lines_under_selection(self, view, number_of_lines_to_show):
        cursor_pos = view.sel()[0].end()
        row, col = view.rowcol(cursor_pos)
        desired_pos = view.text_point(row + number_of_lines_to_show, col)
        if not view.visible_region().contains(desired_pos):
            view.show(desired_pos, False)

    def on_post_text_command(self, view, command_name, args):
        if command_name in ('word_highlight_click', 'move', 'move_to', 'insert'):
            self.show_lines_under_selection(view, 10)

    def on_post_window_command(self, window, command_name, args): # for Vintageous support
        if command_name in ('press_key'):
            self.show_lines_under_selection(window.active_view(), 10)

将其保存到它建议的文件夹中,如 show_lines_under_cursor.py

这将确保光标下始终有 10 条可见行。请注意,一旦到达文件底部,它就不会再滚动以显示 10 non-existing-in-file 行。我不确定是否可以通过 API.