Panes are just like splits

tmux allows you to have multiple panes (the equivalent of windows in Vim) and windows (the equivalent of tabs). To access tmux functionality, you first need to hit a prefix key, followed by a command. The default prefix key is Ctrl + b.

You can rebind the default prefix key to something else by creating or editing your ~/.tmux.conf file. For example, if you wanted to use Ctrl +  as a prefix instead of Ctrl + b, you would add the following:

# Use Ctrl- as a prefix.
unbind-key C-b
set -g prefix 'C-'
bind-key 'C-' send-prefix

Restart tmux (or execute Ctrl + b followed by :source-file ~/.tmux.conf) to apply the configuration.

To split the screen vertically, use Ctrl + b followed by %:

For some reason, I could never get used to the default bindings. I remember hyphen - is a lot easier for creating vertical splits. My ~/.tmux.conf file contains the following:

# Use - to create vertical splits.
bind - split-window -v
unbind '%'

To create a horizontal split, hit Ctrl + b, followed by ":

The same as with vertical splits, I find the pipe character | to be a lot easier to remember for creating horizontal split windows. My ~/.tmux.conf file contains the following:

# Use | to create horizontal splits.
bind | split-window -h
unbind '"'

You can navigate the panes by using Ctrl + b followed by an arrow key. Every pane operates independently, and you can change directories, execute commands, and (most importantly) use Vim in each one of the panes.

If you're already used to hjkl, arrow key navigation might feel unwieldy. Add the following to your ~/.tmux.conf file to add hjkl movement support:

bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

In the following example, I have a file with some code loaded into the left-hand pane; I'm editing .vimrc in the upper-right pane and listing files with ls in the lower-right pane:

Exit the session by executing exit or hitting Ctrl + d to close the pane.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.114.38