Inception: Xmonad > Tmux > Vim
Let me tell you the story of my current desktop setup. Xzibit could be proud, because everything is deeply nested.
Level 1 - Xmonad - Key: super
Here I am, staring at my 3 physical monitors. They all have different input (laptop, HDMI and VGA) and resolutions, but Xmonad handle them with no issue.
In the Xmonad world the super key is king. It always have the same function and it's never shadowed by any application.
So to move the focus between these 3 monitors, I simply press super+q, super+w and super+e on the top row.
Each monitor is in charge of displaying a workspace. I usually have 10 of them, but only 3 can be shown at any time.
To switch between workspace, I press super+1, super+2 using the numbers row.
For instance, to display the firefox workspace (number 2) on the HDMI output: super+wsuper+2.
What's displayed on each workspace? X windows! There can be many of them and they are organized in a layout: in columns, in rows, in accordions…. Here again it's Xmonad responsibility to tile them and make sure they never overlap.
To open a new terminal in the focused workspace super+return. Press again to open another on the side. To navigate between these X windows: super+hjkl.
What's next? Typing
tmux in one of the terminal.
Level 2 - Tmux - Key: ^a
Sessions and clients
By typing the
tmux command, two things happen in the current terminal. A session is created in background by the tmux server and a tmux client is attached to it. In another terminal, you can choose to create a client connected to the same session or to a new one. The beauty is that if 2 clients are connected to the same session, the display is synchronized between them. Which means that you can achieve some kind of mirror mode by displaying a tmux client on 2 different physical monitors.
Each session can have many tmux windows attached. Their names is displayed in the status bar at the bottom. ^a n and ^a p let you switch to the next or previous window.
Tmux windows can be split in tmux panes. Each pane displays its own terminal. To move the focus between these panes ^a hjkl is used. Notice that it's a similar approach than to move between X windows. Only the prefix key changes.
vim in one this tmux pane…
Level 3 - Vim - Key: space
When vim is loaded, here's what is displayed: 1 tabpage, containing 1 window, in charge of 1 buffer. Wow! And to rule them all, let me introduce you space, vim's leader key remap just under your thumbs.
In vim, a tabpage usually handles 1 (code) project. So you can decide to have many tabpages opened for different projects, but only one is shown at any given time. Many commands starting by
:tab are used to switch between them.
Windows and splits
At the beginning only 1 vim window is displayed. But if you need to display two files side by side, or even the same file but you need to see the beginning and the end simultaneously, you can split the window. Horizontally or vertically. To change the focus between splits? Easy: space hjkl! Same logic.
Extra level - Neovim :term
If you use neovim, a new
:term has been added recently. With this new functionality, you can open a real terminal in a split…. A step too far?
Ready to dive again?
Physical monitor → Xmonad Workspace → X window → Tmux client → Tmux window → Tmux pane → Vim tabpage → Vim split → Vim window → Vim buffer
Don't get lost. It could have been worse with terminator as terminal emulator.