Search This Blog

Wednesday, March 27, 2013

Custom 3 pane layout in Sublime

I work with many files and often I need to copy and paste various lines when editing them. What help me a lot was a nice 3 pane layout where I could move files around. One way to create it is to use the Origami plugin that you can install in Sublime. But to make it simpler I decided to create a keyborad shortcut/menu entry for this.

The layout looks like this:


This is the config you need to put:
  • create a config file Main.sublime-menu in your sublime2\Data\Packages\User directory
  • copy the config into the file
[{
    "id": "view",
    "children": [{
        "id": "layout",
        "children": [{
             "command": "set_layout",
             "caption" : "Custom: 3 Pane",
             "mnemonic": "C", 
             "args": {
        "cells": [[0, 0, 1, 1], [0, 1, 2, 2], [1, 0, 2, 1]],
     "rows": [0.0, 0.5, 1.0], 
     "cols": [0.0, 0.5, 1.0]
   }
  }]
 }]
}]
  • Before you save the file open console (view->show console) and see if the file is parsed and loaded properly
# on the console
found 11 files for base name Main.sublime-menu
  • If you need now to divide your screen you need to select View->Layout->Custom:3 Pane from menu
  • You can create a custom keyboard shortcut as well. To replace the original [alt+ctrl+3] open the Preferences -> Bindings -> User and copy this similar config there. 
  • {
        "keys": ["alt+shift+3"],
        "command": "set_layout",
        "args": 
        {
            "cells": [[0, 0, 1, 1], [0, 1, 2, 2], [1, 0, 2, 1]],
            "rows": [0.0, 0.5, 1.0], 
            "cols": [0.0, 0.5, 1.0]
        }
    }
    
References
  1. http://www.macdrifter.com/2012/07/sublime-text-working-with-multiple-panes.html
  2. http://stackoverflow.com/questions/13149800/custom-layouts-sublime-text-2
  3. http://stackoverflow.com/questions/10674030/in-sublime-text-2-reopen-build-output

No comments:

Post a Comment