在Sublime Text窗口的两列中显示相同的文件

问题描述 投票:188回答:9

当我在Sublime Text窗口中设置了2列时,是否可以在两列中显示相同的文件?

sublimetext2 sublimetext sublimetext3
9个回答
291
投票

是的你可以。打开文件后,单击File -> New View Into File。然后,您可以将新选项卡拖到另一个窗格并查看该文件两次。

有几种方法可以创建新窗格。如其他答案中所述,在Linux和Windows上,您可以使用AltShift2(OS X上的选项⌥命令⌘2),它对应于菜单中的View → Layout → Columns: 2。如果您安装了优秀的Origami插件,则可以在Windows / Linux上使用View → Origami → Pane → Create → Right或CtrlK,Ctrl→chord(在OS X上将Ctrl替换为⌘)。


91
投票

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


62
投票

在sublime编辑器中,找到名为View的标签,

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

10
投票

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

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]]

6
投票

我经常在两个不同的位置处理同一个文件。我使用origamichain以及一些额外的配置在Sublime Text 3中解决了这个问题。

我的工作流程是ctrl-k 2将文件的视图拆分为两个(水平)窗格,其中较低的一个窗格处于活动状态。使用ctrl-k o在窗格之间切换。完成后,确保下部窗格处于活动状态,然后按ctrl-f4关闭复制的视图和窗格。

在崇高的全局设置(不是折纸设置!)添加

"origami_auto_close_empty_panes": true,

添加以下快捷方式

  { "keys": ["ctrl+k", "2"], 
    "command": "chain", 
    "args": {
      "commands": [
        ["create_pane", {"direction": "down"}],
        ["clone_file_to_pane", {"direction": "down"}],
      ],
    }
  },

  { "keys": ["ctrl+k", "o"], "command": "focus_neighboring_group" },

2
投票

我建议你使用Origami。它是分割屏幕的绝佳插件。有关键盘快捷键的更好信息,请安装它并在重新启动Sublime文本后打开Preferences->Package设置->折纸->键绑定 - 默认

有关您的问题的具体问题,我建议您查看与上述文件中的文件克隆相关的捷径。


2
投票

可以在分割模式下编辑同一文件。最好在以下YouTube视频中进行说明。

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


2
投票

查看 - >布局 - >选择一个选项或使用快捷方式

Layout        Shortcut

Single        Alt + Shift + 1
Columns: 2    Alt + Shift + 2
Columns: 3    Alt + Shift + 3
Columns: 4    Alt + Shift + 4
Rows: 2       Alt + Shift + 8
Rows: 3       Alt + Shift + 9
Grid: 4       Alt + Shift + 5

enter image description here


1
投票

有点晚,但我试图扩展@Tobia's answer以设置由命令参数驱动的“水平”或“垂直”布局,例如

{"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]]
            })
© www.soinside.com 2019 - 2024. All rights reserved.