Sublime Forum

Split view

#1

how do you split the current view into 2? If I hav a document open, and want two views of the same doc, I choose “layout > 2 rows” but then I get an empty bottom row. There seems to be no way to get the current document into it.

I must be missing something here.

1 Like

Simpler split view
#2

Menu item “File->New view into File”

0 Likes

#3

And then drag the tab down to the new tab bar? That seems to work, thanks. But it does seem like a lot of work to simply split a document into 2 scrolling view, plus both views have a tab.

I guess I am used to BBEdit, just drag the “splitter” on the scroll bar and voila.

https://img.skitch.com/20120531-prsimyit3b678inw9nbdr5qmgb.jpg

0 Likes

#4

I agree that having to split the window isn’t very intuitive. A lot of times I just want to reference another portion of the file I am working on and don’t want to split the window for all other files open. Hopefully this will be addressed at some point. I haven’t seen a way to just split the window for the current document unless I am missing something.

Scott

1 Like

#5

You can create the splitted layout and move the cloned view to the second group automatically with something like this:

[code]import sublime_plugin

class CloneFileToGroupCommand(sublime_plugin.WindowCommand):
def run(self):
if self.window.num_groups() == 1:
self.window.run_command(‘set_layout’,
{
“cols”: [0.0, 0.5, 1.0],
“rows”: [0.0, 1.0],
“cells”: [0, 0, 1, 1], [1, 0, 2, 1]]
})
self.window.run_command(‘clone_file’)
self.window.run_command(‘move_to_group’, {“group”: 1})[/code]
or even with a macro.

It’s probably possible to analyze the current layout, add another group next to the current one and clone the view to this group.
And maybe save the old layout for reverting to it when you finished the work.
But with the tabs bar (which I don’t show), it’s doesn’t look great.

0 Likes

#6

Here’s the code I’m using, in case others find it useful.

It can be bound to a single key which will make a split view into the current file, just like dragging the horizontal splitter in other editors, or close the split view if it’s open.

This is meant for somebody who uses the Single layout. If you are already using other layouts, then you’ll have to look into more elaborate plugins, such as Origami.

[code]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.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]]
})
[/code]

0 Likes

#7

And then I believe you need to select View/Layout/Rows: 2. I second the motion for more BBEdit-like functionality.

0 Likes