Showing the same file in both columns of a Sublime Text window

186,694

Solution 1

EDIT

With the release of Sublime Text 4, there is now a feature called Split View that you can access a couple different ways. Via the menu system, you can simply use File -> Split View. You can also right-click on a tab and select Split View from the context menu. It automatically opens a new pane with a new view of the file currently selected.

You should be aware that unlike the new pane described below, the new Split View pane is temporary. This means that if you click on another tab or open a new file, the split view disappears. However, the new view into the file remains open as a separate tab, so to reopen the pane (or compare any open file(s)), select the tab you want on the left, then Ctrl-click (Command ⌘-click on macOS) on the other tab(s) you want to compare, and each one will be displayed in its own pane.

If want to have two (or more) "permanent" panes that will stay open regardless of which tab you click on, just follow the directions below.


Original Answer

(For Sublime Text 3)

Yes, you can. When a file is open, click on File -> New View Into File. You can then drag the new tab to the other pane and view the file twice.

There are several ways to create a new pane. As described in other answers, on Linux and Windows, you can use AltShift2 (Option ⌥Command ⌘2 on OS X), which corresponds to View → Layout → Columns: 2 in the menu. If you have the excellent Origami plugin installed, you can use View → Origami → Pane → Create → Right, or the CtrlK, Ctrl chord on Windows/Linux (replace Ctrl with on OS X).

Solution 2

Its Shift + Alt + 2 to split into 2 screens. More options are found under the menu item View -> Layout.
Once the screen is split, you can open files using the shortcuts:
1. Ctrl + P (From existing directories within sublime) or
2. Ctrl + O(Browse directory)

Solution 3

Inside sublime editor,Find the Tab named View,

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

Solution 4

Here is a simple plugin to "open / close a splitter" into the current file, as found in other editors:

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

Save it as Packages/User/split_pane.py and bind it to some hotkey:

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

If you want to change to vertical split change with following

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

Solution 5

I regularly work on the same file in 2 different positions. I solved this in Sublime Text 3 using origami and chain with some additional config.

My workflow is Ctrl + k + 2 splits the view of the file in two (horizontal) panes with the lower one active. Use Ctrl + k + o to toggle between the panes. When done ensure the lower pane is the active and press Ctrl + F4 to close the duplicated view and the pane.

In sublime global settings (not origami settings!) add

"origami_auto_close_empty_panes": true,

Add the following shortcuts

  { "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" },
Share:
186,694

Related videos on Youtube

user2777473
Author by

user2777473

Updated on July 08, 2022

Comments

  • user2777473
    user2777473 almost 2 years

    When I have 2 columns set in a Sublime Text window, can I display the same file in both columns?

  • zadubz
    zadubz over 9 years
    Ctrl+Shift+2 shortcut for split screen and drag the file over
  • sg28
    sg28 over 8 years
    View --> Layout --> "select your need" select your needs = [single,columns,rows,grids]. So this means the options available when you go to Layout .try out first ,Tested in Sublime 2.
  • Shital Shah
    Shital Shah about 8 years
    You can also use Windows+Ctrl+arrow key to arrange windows.
  • jayflo
    jayflo about 8 years
    To expand, CTRL + P will allow you to "open" the same file more than once.
  • wehal3001
    wehal3001 almost 8 years
    to make the chain command work (seen in the shortcut), you will also need the Chain of Command package installed.
  • mrtnlrsn
    mrtnlrsn almost 8 years
    @wehal3001 Thanks, updated (also updated the globals settings, where the wrong setting was pasted).
  • LED Fantom
    LED Fantom over 7 years
    The cmd in the next post works - shift + Alt + 2 to split into 2 screens, not this one below.
  • MattDMo
    MattDMo over 7 years
    @LEDFantom When you say this answer doesn't work, what do you mean? The OP already knew how to create split windows, which is why I didn't explain how to do that in my answer. I'm not sure what the downvote is for.
  • LED Fantom
    LED Fantom over 7 years
    @MattDMo , I see what you meant now. How do I remove the down vote?
  • MattDMo
    MattDMo over 7 years
    @LEDFantom I just edited the post, so you can remove it if you wish. Thanks!
  • Reverse Engineered
    Reverse Engineered over 6 years
    It makes me sad that this option is in the File menu and not the View menu.
  • keen
    keen over 6 years
    appreciate the menu navigation instead of just a shortcut which happens to work for some users and doesn't explain what sublime feature is in use - which the menu clearly defines. :)
  • VaTo
    VaTo over 5 years
    This should be the only accepted, this is what worked for me. The accepted one doesn't work anymore. Probably it doesn't work in current versions.
  • Tagman
    Tagman over 3 years
    CTRL + O will not
  • Gabriel Staples
    Gabriel Staples about 3 years
    File --> New View Into File seems to be gone entirely in Sublime Text 4. :(
  • Gabriel Staples
    Gabriel Staples about 3 years
    Found it! In Sublime Text 4: File --> Split View.
  • MattDMo
    MattDMo about 3 years
    @GabrielStaples thanks for the tip, I've expanded my answer to include Split View.
  • Nick K9
    Nick K9 about 2 years
    The video has been removed. This is why SO doesn't encourage answers which are just links.