Switch between layouts in Sublime Text 3 - sublimetext3

I'm working in a project with lots of files and switching between different tasks. And having a lot of files open at once clog the tabs in the panes (and my brain). So therefore I would like to be able to switch out all my panes/views much like switching workspace in Linux. And when I switch back it remembers the files/views/tabs.
In short: ability to toggle between this:
Layout 1 Layout 2
---------------------------- ----------------------------
| | | | | |
| file a | file a2 | | file b | file b2 |
| (+3 tabs) | | | | |
| | | | | |
| | | | | |
| |-------------| | | |
| | file a3 | | | |
| | | | | |
---------------------------- ----------------------------
Does Sublime 3 has this functionality or is there a package that can help with this?

Here is detail explenation for layout creating in sublime text : example
My suggestion is to create those two layouts and put key shortcut for both.
Install chain of command plugin. Create key shortcut for mulitple commands :
1. set layout 2
2. move focus to group 1
3. open "file b" by name [plugin]
4. move focus to group 2
5. open "file b2" by name [plugin]
Do same thing for layout 1 scenario. Here is example how to create plugin for opening file by name how-to-open-file-using-only-keyboard-in-sublime-text . You need to modify some part of that plugin because it use input dialog.

Related

Can we combine grid layout and terminal panel in vscode?

There is the grid layout in vs-code, and there is the terminal panel. Is there a way to combine both?
Lets say I want this :
--------------------------------------------------------------
| | |
| | |
| | |
| | something |
| | here |
| editor here | |
| | |
| | |
| |---------------------------|
| | |
| | |
| | terminal |
| | here |
| | |
| | |
| | |
--------------------------------------------------------------
I know we can put the terminal on the right, but I do not know if we can put it in the bottom of the right column. It works with other panel though, like editor.
To my best understanding, you cannot put the whole terminal panel (thinking of the combined: problems, output, debug console, terminal, ... group) in the grid layout.
However, you can put individual terminal shells into the editor and they will behave like opened files, able to be moved between editor panes.
After you have opened the terminal panel, you can drag and drop the shell's name (located just left of the little + sign where you can create a new terminal. It will have a name like bash or any other shell you are using) into the editor.
To make it easier, there is a setting for terminal.integrated.defaultLocation where you can specify the value to be editor. You split the editor panel as you see fit and then press workbench.action.terminal.new (default keycode is Ctrl+`) and you terminal will appear in the selected grid section.

NERDTree: Opening a file below the file explorer

I'm using NERDTree and (1) want to have the following layout in a single window to save the resolution in the horizontal direction. Does NERDTree support such a layout? In addition, I need to (2) arrange the display ratio in the vertical direction.
-----------------------------------
| |
| File Explorer: |
| |
| Always open. |
| |
-----------------------------------
| |
| Multiple Files: |
| |
| Only a single file is |
| displayed. You can display |
| a specific file in the |
| buffer invoking ":b [n]". |
| |
-----------------------------------
By default NEDTree opens files on the right of the file explorer as follows:
-----------------------------------
| | |
| | |
| | |
| F.E. | Multiple Files |
| | |
| | |
| | |
-----------------------------------
I do not use nerdtree, but a quick search in the source shows following lines:
call s:initVariable("g:NERDTreeWinPos", "left")
call s:initVariable("g:NERDTreeWinSize", 31)
So i bet you can use this in your .vimrc:
let g:NERDTreeWinPos = "top"
let g:NERDTreeWinSize = X
For the ration you can do some math with the &lines variable.
However you will have to do this in two autocmds VimResized and BufEnter and probably BufNew too.
There are a lot of questions and answers about autocmd on SO so i will not explain it any further unless you need some specific help.

Splitting workspaces in the notion window manager

I have been using the Notion Window Manager (http://notion.sourceforge.net/) for a few weeks. I was wondering if it is possible to create a keybinding that splits a workspace in the same way that META+S and META+K S splits a frame horizontally and vertically.
So if I had two vertical frames in a workspace like this:
-----
|1|2|
| | |
| | |
| | |
-----
The keybinding to split horizontally should add a new frame that spans the workspace horizontally:
-----
|1|2|
| | |
-----
| 3 |
-----
Currently META+S only splits the selected frame horizontally:
-----
|1|2|
| | |
|-| |
|3| |
-----
Is there any way to accomplish splitting the entire workspace horizontally or vertically in Notion?
The solution I came up with is to add a keybinding to the split_top function in cfg_tiling.lua. To split horizontally I added:
kpress(META.."Z", "WTiling.split_top(_, 'bottom')")
to the WTiling defbindings function. I also added
kpress("Z", "Wtiling.split_top(_, 'left')")
to the submap META.."K" bindings.
The split_top function splits at the root of the split tree. This will create a new frame that splits the entire workspace rather than the current frame.
One sizing issue that I noticed with this approach is that it will try to split the workspace exactly in half. If there is a horizontal frame splitting a workspace split_top will resize it to the smallest size and add a new frame below it. If there is a vertical frame it will become about 10 pixels wide when the new frame is added.
Horizontal size issue. New frames are 0 height:
Start ->Mod1+Z ->Mod1+Z
-1--2-- -1--2-- -1--2--
| | | | | | | | |
| | | | | | | | |
-3----- -3----- -3-----
| | -4----- -4-----
| | | | -5-----
| | | | | |
| | | | | |
------- ------- -------
Vertical size issue. New frames are 0 width:
Start -> Mod1+K Z -> Mod1+K Z
-1----2---- -4--1-2---- -5-41-2----
| | | | || | | ||| |
| | | | || | | ||| |
| |3---| | ||3---| | |||3---|
| | | | || | | ||| |
| | | | || | | ||| |
----------- ----------- -----------
Another issue is the focus does not change to the newly create frame. Hitting Mod1+Z will create the frame but the user has to Mod1+TAB to the frame to manipulate it.
This is a start but a comprehensive solution would check for frames that already split the workspace and split them instead and change the focus to the new frame.
Yes, you can.
You either need to put your binding in the workspace context or from the frame/mplex context you need to look up the managing workspace and then call split on that.
(I'd post code and more concrete terms but I'm not in front of a notion machine at the moment and don't want to confuse things by using the wrong ones.)

Write a command to increase or decrease the number of vertical splits

I usually have my Vim screen split into two vertical windows, each of which may be further horizontally split. Sometimes, I want to add or delete a vertical window. Is there a way to detect how many top-level vertical splits there are and add or remove vsplits as necessary?
For example, suppose my screen looks like this:
+--------+--------+
| | |
| | |
+--------+ |
| | |
| | |
| +--------+
| | |
+--------+--------+
I want :Columns 1 to give me
+--------+
| |
| |
+--------+
| |
| |
| |
| |
+--------+
by closing the two right-most windows.
I want :Columns 2 to do nothing, detecting that two columns are already open.
And I want :Columns 3 to give me
+--------+--------+--------+
| | | |
| | | |
+--------+ | |
| | | |
| | | |
| +--------+ |
| | | |
+--------+--------+--------+
I am fine if the function ignores vertical splits within horizontal splits. For example, if I had
+--------+
| |
| |
+---+----+
| | |
| | |
| | |
| | |
+---+----+
and I ran :Columns 2, I would get
+--------+--------+
| | |
| | |
+---+----+ |
| | | |
| | | |
| | | |
| | | |
+---+----+--------+
There is indeed a way, but it is involved; the first step is to count the currently-open vertical windows, and I don’t know of any built-in function that facilitates this. The working approach I found to it is basically to start at the first window (the top of the first — if not the entirety of the first — vertical split), and to then, using wincmd l, move to the next window to the right for as long as wincmd l moves to a new window, adding each to a count of open vertical windows including the first one. (I think this is what Gary Fixler referred to in the comments on the question.)
I started trying to write the code for posting here, and it grew to become larger than any function I would want to put in my ~/.vimrc, so I ended up turning it into a plugin which takes the above approach and provides the :Columns command; see Columcille (on vim.org at http://www.vim.org/scripts/script.php?script_id=4742.) The plugin also provides a command for similarly managing horizontal split windows: :Rows divides the current column (or the main window, if there are no open vertical splits) into the specified number of “rows.”

How to move vertical split window to horizontal split, when there is an existing horizontal split?

In Vim I tend to open buffers in new vertical splits (with the occasional horizontal split). I keep my code to 80 chars wide, so this works pretty well on large monitors.
I often end up with this window arrangement:
---------------------
| | | | |
| | | | |
------ | A | B |
| | | | |
| | | | |
---------------------
At four or five columns wide, it can start getting a bit too narrow, so then I want to move the windows around so it looks like this:
----------------
| | | A |
| | | |
------ ------
| | | B |
| | | |
----------------
As far as I know, this is impossible to do by moving the windows in Vim.
The only way to get that window arrangement I've found, is to close window A, and then re-open A as a new horizontal split from window B.
Is that correct, or is there a way to move/re-arrange windows like that in Vim? Maybe a plugin?
I'm yet to find anything, so I thought I would ask because I find the opening/closing of windows anoying and breaks my flow.
FWIW, I find the Ctrl-W + J / Ctrl-W + K shortcuts useless, because they make the new horizontal split as wide as the whole screen, rather than splitting with the neighbouring window. I.e. Ctrl-W + J would give me this:
----------------
| | | |
| | | |
------ | A |
| | | |
| | | |
----------------
| |
| B |
----------------
Which is generally never what I want.
If anyone has some ideas, let me know!
There's a plugin that can do exactly what you want. Here's the link : https://github.com/fabi1cazenave/suckless.vim.

Resources