Tmux and Vim: the perfect combination
Last night at Vim London I spoke about some of my favourite plugins and settings for Tmux and Vim that allow me to work with them as I do. It’s very rare these days that I won’t be editing code from Vim, within a Tmux session, but out of the box the immediate advantages of this pairing are not always obvious. It takes some time to get things working.
The talk was recorded and I will update the post with it once it’s public, but for now I just wanted to link to some of the plugins and settings I mentioned in the talk that I use in my dotfiles.
tnew
alias
I create all my tmux sessions through an alias I have which I’ve called tnew
, which simply calls a function called new-tmux-from-dir-name
(this is taken from the thoughbot dotfiles. The function looks like so:
sh function new-tmux-from-dir-name { tmux new-session -As `basename $PWD` }
This does two things: – when you create a new session, it names it based on the directory name – if you are in a directory that already has a tmux session associated, tnew
will attach you back into the already existing session
Tmux + OS X, pbcopy
By default tmux on OS X breaks the pbcopy
command. I’m not going to go into details, but thankfully Chris Johnsen’s fix
has detailed instructions on how to get that functionality back, and it’s not too tricky either.
Renumber windows
Out of the box, if you have 3 tmux windows numbered 0, 1, 2 and then you delete the one numbered ‘1’, you’re left with two windows: 0, and 2.… Click Here