kilabit.info
| AmA | Build | Email | GitHub | Mastodon | SourceHut

Someone ask on /r/vim: What are a sane set of key bindings between i3wm? It’s good question, because all of the programs is keyboard friendly, less-mouse, navigation.

Before we look into my keybindings, you must understand why or how I use those three programs.

The key here is to trying,

  • not to customize as many as keybindings, so your brain can work in other non customized environment seamlessly.

  • not to use split pane on tmux, or split edit on vim. Use new window or new tab instead.

i3

The meaning of workspaces in i3 is a group of application/projects/windows. For example, my i3 workspace names are,

  • net: for email and browser

  • devops: for devops related tasks

  • remote: for list of terminal that open SSH connection

  • backend: for list of terminal that open backend project

  • media: for watching movie, Spotify window

  • and so on.

So the only keybindings I need are switching between workspaces and moving windows between workspaces,

  • Ctrl+alt+left to move the the left workspace,

  • Ctrl+alt+right to move to the right workspaces,

  • Win+x , where x is number between 1-0, to quickly jump into workspaces;

  • Win+Shift+x, to move window into workspace number x (0-9)

A sample of keybindings config in i3,

bindsym $mod+1 workspace $WS1
bindsym $mod+2 workspace $WS2
...

bindsym Mod1+Control+Left workspace prev
bindsym Mod1+Control+Right workspace next

## move focused container to workspace
bindsym $mod+Shift+1 move container to workspace $WS1
bindsym $mod+Shift+2 move container to workspace $WS2
...

tmux

A single i3 workspace contains many programs (terminal, browser, etc). Each terminal must run with tmux.

For example, in the backend workspaces I have tmux session. The session name is equal with project name or remote name. Let say repo-x. Inside this session I usually open three or four tmux’s shell (or window): one shell to edit, one shell to compile and running test, and other shell for everything else.

To create a new shell, I use standard tmux keybindings: Ctrl+b+c.

To move between shell, I use

  • Ctrl+pgup to switch to the right shell, and

  • Ctrl+pgdown to switch to the right shell.

A sample of keybindings in tmux config would be,

bind -n C-PPage        prev
bind -n C-NPage        next
bind -n S-PPage swap-window -t -1
bind -n S-NPage swap-window -t +1

I have list of predefined session name that I can open using rofi. If session is not exist it will create one, otherwise it will attach into it (similar with tmux new -As name).

vim

I use vim with many tabs open. Each contains one buffer. To move to previous or next tab my keybindings are alt+[ and alt+]. Others keybindings are default.

A sample of keybindings in nvim config,

"" Shortcut to move tab to left / right.
map   :tabprevious
map!  :tabprevious

map   :tabnext
map!  :tabnext

"" ALT + {: move tab to the left
map   :tabmove -1
map!  :tabmove -1

"" ALT + page-down: move tab to the right
map   :tabmove +1
map!  :tabmove +1

Before someone complain that I use tabs wrong, I will said that you are using buffer wrong. Buffer is internal vim objects, user should not interact with it directly - listing buffer, displaying as tab, etc.