当我有2列设置在一个崇高的文本窗口,我可以显示相同的文件在两个列?


当前回答

在sublime编辑器中,找到名为View的选项卡,

View --> Layout --> "select your need"

其他回答

这是一个简单的插件,可以在当前文件中“打开/关闭拆分器”,就像在其他编辑器中一样:

import sublime_plugin

class SplitPaneCommand(sublime_plugin.WindowCommand):
    def run(self):
        w = self.window
        if w.num_groups() == 1:
            w.run_command('set_layout', {
                'cols': [0.0, 1.0],
                'rows': [0.0, 0.33, 1.0],
                'cells': [[0, 0, 1, 1], [0, 1, 1, 2]]
            })
            w.focus_group(0)
            w.run_command('clone_file')
            w.run_command('move_to_group', {'group': 1})
            w.focus_group(1)
        else:
            w.focus_group(1)
            w.run_command('close')
            w.run_command('set_layout', {
                'cols': [0.0, 1.0],
                'rows': [0.0, 1.0],
                'cells': [[0, 0, 1, 1]]
            })

保存为Packages/User/split_pane.py,并将其绑定到某个热键:

{"keys": ["f6"], "command": "split_pane"},

如果你想更改为垂直分割更改如下

        "cols": [0.0, 0.46, 1.0],
        "rows": [0.0, 1.0],
        "cells": [[0, 0, 1, 1], [1, 0, 2, 1]]

它的Shift + Alt + 2分为2个屏幕。在菜单项View -> Layout下可以找到更多选项。 一旦屏幕被分割,你可以使用快捷方式打开文件: 1. Ctrl + P(从sublime中的现有目录中)或 2. Ctrl + O(浏览目录)

可以在分割模式下编辑同一文件。 最好的解释是下面的youtube视频。

https://www.youtube.com/watch?v=q2cMEeE1aOk

在sublime编辑器中,找到名为View的选项卡,

View --> Layout --> "select your need"

有点晚了,但我试图扩展@Tobia的答案,以设置由命令参数驱动的布局“水平”或“垂直”。

{"keys": ["f6"], "command": "split_pane", "args": {"split_type": "vertical"} } 

插件代码:

import sublime_plugin


class SplitPaneCommand(sublime_plugin.WindowCommand):
    def run(self, split_type):
        w = self.window
        if w.num_groups() == 1:
            if (split_type == "horizontal"):
                w.run_command('set_layout', {
                    'cols': [0.0, 1.0],
                    'rows': [0.0, 0.33, 1.0],
                    'cells': [[0, 0, 1, 1], [0, 1, 1, 2]]
                })
            elif (split_type == "vertical"):
                w.run_command('set_layout', {
                    "cols": [0.0, 0.46, 1.0],
                    "rows": [0.0, 1.0],
                    "cells": [[0, 0, 1, 1], [1, 0, 2, 1]]
                })

            w.focus_group(0)
            w.run_command('clone_file')
            w.run_command('move_to_group', {'group': 1})
            w.focus_group(1)
        else:
            w.focus_group(1)
            w.run_command('close')
            w.run_command('set_layout', {
                'cols': [0.0, 1.0],
                'rows': [0.0, 1.0],
                'cells': [[0, 0, 1, 1]]
            })