• No results found

Panes

In document Sublime Productivity (Page 36-43)

Sometimes it’s handy to keep two or more files visible on screen at the same time. Maybe you’re writing some Backbone.js code and need to see the library’s commented source code as a reference, or maybe you’re hacking an HTML prototype together and find yourself constantly jumping from HTML to CSS and back. You could tear tabs off and create a second Sublime window, but Sublime provides a better solution with panes.

Panes allow you to view and edit multiple files in one window in a variety of configurations, including vertical and horizontal splits and various combinations of the two.

Layouts vs. groups

Sublime offers two tools for managing multiple panes: layouts and groups.

Layouts

Layouts are preconfigured arrangements of panes. You can choose from one, two or three horizontal splits, up to four vertical splits, or a 2-by-2 grid.

Using layouts is convenient if one of the supported configurations meets your needs, and it’s the only way to achieve a 2-by-2 grid.

Panes created by a layout persist until you change layouts, regardless of whether they contain any tabs.

Groups

Groups, on the other hand, are more flexible. There’s no limit to the number of groups you can create. You can also combine horizontal and vertical splits, although as we’ll see, the combinations are somewhat limited.

Using groups, you could split your editor window into two columns, then split the right column into two rows.

Groups are also more dynamic than layouts. A group’s pane closes when you close the last tab it contains.

Panes 22 Version Difference!

The concept of groups is new in Sublime Text 3, and Sublime Text 2 only supports layouts.

While layouts are still relevant for Sublime Text 2 users, most ST3 users will likely prefer the additional flexibility that groups offer. The main advantage that layouts still have in Sublime Text 3 is the 2-by-2 grid configuration, which isn’t achievable with groups.

Managing layouts

To open a multi-column layout, click View | Layout | Columns: 2, View | Layout | Columns: 3, or View | Layout | Columns: 4.

To open a multi-row layout, click View | Layout | Rows: 2 or View | Layout | Rows: 3.

To create a two-by-two grid layout ,click View | Layout | Grid: 4.

To revert to the default layout, click View | Layout | Single.

When you change layouts, the new panes appear to the right or below existing panels, and they don’t have any tabs assigned to them by default.

If you switch to a layout with fewer rows or columns, tabs from the panes that disappear are merged into the row above or the column to the left, depending on the type of layout you’re using.

Sublime retains the positioning of tabs when you switch from a multi-row layout to a multi-column layout and vice versa. If you go from a two-column layout to a two-row layout, tabs from the rightmost column move to the newly created bottom row.

Managing groups

Creating groups

To open a new, empty group, click View | Groups | New Group.

You can also create a new group and populate it with the file you’re currently editing in one step.

Just click View | Groups | Move File to New Group.

Arranging groups

The Max Columns setting governs how Sublime arranges groups as you create them. Sublime preferentially creates a new column each time you add a group until you hit the maximum number of columns. Once the maximum number of columns is reached, Sublime starts adding rows to the rightmost column.

Panes 23 To change the the Max Columns setting, click View | Groups and choose the desired number of columns, up to a maximum of five.

It’s easy to create a three-pane split, with two columns and two rows on the right. Starting from the default, single-pane layout, set Max Columns to two, then create two new tab groups.

If you’d like to split your screen horizontally into two rows, set Max Columns to one. Then add a second tab group.

Although it would be handy, it’s not currently possible to add rows to columns on the left side of the screen.

Closing groups

The simplest way to get rid of a tab group is to close all of its tabs or move them to another group.

The group disappears automatically when you remove the last file.

If the current group has a lot of open files, the Close Group command is faster.

To close the current tab group, click View | Groups | Close Group.

When you close a tab group that has open tabs, the files shift to the previous pane in the pane sequence.

Version Difference!

The Close Group command isn’t available in Sublime Text 2.

Rearranging tabs

The simplest way to move a tab from one pane to another is by dragging its tab and dropping it into desired pane.

The Move File commands allow you to accomplish the same task via the menu or keyboard shortcuts.

Move to Next Group

The Move to Next Group command shifts the current tab one column to the right or one row down.

To use Move to Next Group, click View | Move File to Group | Next.

Version Difference!

The Move to Next Group command isn’t available in Sublime Text 2.

Panes 24

Move to Previous Group

Move to Previous Group nudges the current tab left one column up a row, depending on your screen arrangement.

To use Move to Previous Group, click View | Move File to Group | Previous.

Version Difference!

The Move to Previous Group command isn’t available in Sublime Text 2.

Move to numbered group

When you create a multi-pane screen configuration, Sublime assigns numbers to the first nine panes.

You can move tabs by referencing these numbers.

For example, to move the tab you’re editing to the third pane, click View | Move File to Group | Group 3.

Version Difference!

Sublime Text 2 only assigned numbers to the first four panes.

Navigating between panes

When you’re editing files in several panes simultaneously, you’ll probably need to move from file to file frequently. The Focus Group commands make it simple to jump from pane to pane in these scenarios.

Focus Previous Group / Focus Next Group

The Focus Previous Group and Focus Next Group commands allow you to step to the next adjacent pane. These commands are ideal when you’re toggling back and forth between two files.

To use step back by one pane, click View | Focus Group | Previous. To step forward to the next pane, click View | Focus Group | Next. In both cases, focus shifts to the last place you edited in the active tab.

These commands wrap, so running Focus Next Group when you’re on the last pane will focus the first, and Focus Previous Group will jump to the last pane if you’re editing the first.

Version Difference!

Focus Previous Group and Focus Next Group are new in Sublime Text 3.

Panes 25

Focus Numbered Group

The Focus Previous Group and Focus Next Group commands work well when you have two or three panes open, but what if you’re using a 27” monitor and rocking a three-column layout with four rows in the last column? Cycling through half a dozen panes to get to the one you want gets old in a hurry.

Focus Numbered Group allows you to jump directly to a pane with a numeric address. Sublime applies an index to the first nine open panes, numbering columns left to right and then numbering rows top to bottom.

Navigating with the Focus Numbered Group command is a matter of picking the right index for the pane you want.

Columns are indexed left to right, and rows are numbered top to bottom. The only exception is the 2-by-2 grid layout, in which the top row panes are numbered 1 and 2, from left to right, and the bottom row panels are 3 and 4, also left to right.

Version Difference!

Sublime Text 2 only assigned numbers to the first four panes.

For example, to jump to the rightmost column of a four-column configuration, click View | Focus Group | Group 4.

To switch to the bottom-left pane of a grid view, click View | Focus Group | Group 3.

Panes: Separate or not?

Some commands seem to ignore panes, treating all tabs as if they are in the same pane, while others only operate on tabs in the current pane.

Jump Back/Jump Forward and Previous File/Next File act as if the panes don’t exist. If you’re editing a file in the right column, Jump Back might switch focus to the left pane.

But other commands only work within the current pane. Tab numbers start over in each pane, and Previous File in Stack/Next File in Stack cycle through tabs in the active pane only.

Moving files between panes

Once you’re done tweaking your screen configuration, it’s easy to move files around as you work using the Move File to Group commands. When you move a file to another pane, focus shifts to that pane so you can continue editing without missing a beat.

To send the current tab to the next adjacent pane, click View | Move File to Group | Next.

Panes 26 To move the tab you’re editing backwards one pane, click View | Move File to Group | Previous.

You can also move the active file to a pane by number. To move a file to the rightmost pane in a three-column configuration, for example, click View | Move File to Group | Group 3.

Version Difference!

The Move File to Group commands are new in Sublime Text 3.

Resizing panes

You can resize horizontal and vertical splits to better fit the task at hand.

To resize a pane, hover your cursor over the thin separator line until it turns into a double arrow, then drag the pane to the desired size.

Saving and restoring multi-pane configurations

Sublime will save and restore your custom pane configurations when you close and restart the program. If you’re working on in a project, any custom layouts you create are stored in the associated sublime-workspacefile. When you’re just working on several unrelated files, Sublime will save your layout tweaks in thesublime_sessionfile.

Split View of a Single File

While it’s great to keep code files short and concise, sometimes there’s just no getting around that mammoth FAQ page or that epic jQuery plugin file. Naturally the FAQ page has a list of anchor tags that you have to update as you add sections at the bottom, and the jQuery file has 20 local variables declared at the top that you need to refer to constantly.

In this situation, the New View into File command will save your scroll wheel—and your sanity.

This command opens a copy of the current file in a new tab. Changes made in one tab are reflected instantly in the other tab.

To use New View into File, click File | New View into File.

When you combine this with a multi-pane layout, you’ll find yourself with less need to scroll and jump around in the document, and you won’t lose your place as often.

You can create as many new views as you’d like, and you could even create a grid showing four different sections of the file. Since each view is just a new tab, you can push them to different panes with the Move File to Group command and jump between views with the Focus Group command.

II Using the Editor

In document Sublime Productivity (Page 36-43)

Related documents