当我有2列设置在一个崇高的文本窗口,我可以显示相同的文件在两个列?
当前回答
有点晚了,但我试图扩展@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]]
})
其他回答
有点晚了,但我试图扩展@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]]
})
我经常在两个不同的位置处理同一个文件。我在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" },
这是一个简单的插件,可以在当前文件中“打开/关闭拆分器”,就像在其他编辑器中一样:
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]]
在sublime编辑器中,找到名为View的选项卡,
View --> Layout --> "select your need"
View -> Layout ->选择一个选项或使用快捷方式
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
推荐文章
- 在Sublime Text 2中使用Ctrl+D进行多个选择时,我如何跳过匹配?
- 崇高的文本从命令行
- Sublime Text 3,将空格转换为制表符
- 在Sublime文本窗口的两列中显示相同的文件
- 在Sublime Text 2中限制文件搜索范围
- 如何修复/转换崇高文本的空间缩进?
- 如何使Sublime Text成为Git的默认编辑器?
- 如何在SSH上使用Sublime
- CMD打开Windows Store当我输入'python'
- 如何使标尺始终显示在崇高的文本2?
- Sublime Text 2:如何删除空白/空行
- Sublime Text 3中80个字符/右边距
- 如何从Sublime Text 2运行Python代码?
- 如何在Sublime Text 2中用制表符替换四个空格?
- 在Sublime Text 3中搜索一个项目中的所有文件