Ⅰ. 插件描述
Seamless navigation between tmux panes and vim splitsⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'amiel/vim-tmux-navigator-sparks-fly'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'amiel/vim-tmux-navigator-sparks-fly'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'amiel/vim-tmux-navigator-sparks-fly'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/amiel/vim-tmux-navigator
Ⅳ. 文档说明
Vim Tmux Navigator
This plugin is a repackaging of [Mislav Marohnić's][] tmux-navigator
configuration described in [this gist][], and a slight rewrite of
[christoomey's plugin][] that this is a fork of and also incorporates
the zoom idea from [svenfuchs' gist][].
When combined with a set of tmux key bindings and the provided ruby script,
the plugin will allow you to navigate seamlessly between vim and tmux splits
using a consistent set of hotkeys.
NOTE: This requires tmux v1.8 or higher.
Difference from christoomey/vim-tmux-navigator and other influences
This plugin and it's parts are based on the fine work by [mislav], [christoomey], and [svenfuchs].
There were a few things I wanted to change/incorporate. Here's what I changed:
- This fork adds a zoom feature. When navigating past the last screen in any direction,
(whether it be a vim window or tmux split), this plugin with toggle the tmux zoom feature. - This fork uses an external script instead of large inlined shell script. This makes
setup a little more complicated, but simplifies the tmux config. It also requires ruby. - [svenfuchs' gist][] sends :ex commands to vim. Because of this, moving between vim splits
doesn't work in insert mode. This fork overrides F1-8 keys, which allows the movements to work
in any vim mode. If you use vim mappings for F keys, this plugin probably won't work. However,
you should be able to pick your own "secret" mappings in tmux-vim-select-pane.rb.
- I do not use the toggle between last active pane feature, so I have not tried to get it to work.
Usage
This plugin provides the following mappings which allow you to move between
Vim panes and tmux splits seamlessly.
<ctrl-h>=> Left<ctrl-j>=> Down<ctrl-k>=> Up<ctrl-l>=> Right
When using any of these keys when moving would move off the screen will
Note - you don't need to use your tmux prefix key sequence before using
the mappings.
Installation
Vim
If you don't have a preferred installation method, I recommend using [vim-update-bundles][].
Assuming you have Vundle installed and configured, the following steps will
install the plugin:
Add the following line to your ~/.vimrc file
" Bundle 'amiel/vim-tmux-navigator'tmux-vim-select-pane.rb
Download [tmux-vim-select-pane.rb][]; make sure it is executable and in your path.
Tmux
Add the following to your tmux.conf file to configure the tmux side of
this customization.
# Smart pane switching with awareness of vim splits
bind -n C-k run-shell 'tmux-vim-select-pane.rb -U'
bind -n C-j run-shell 'tmux-vim-select-pane.rb -D'
bind -n C-h run-shell 'tmux-vim-select-pane.rb -L'
bind -n C-l run-shell 'tmux-vim-select-pane.rb -R'Restoring Clear Screen (C-l)
The default key bindings include <Ctrl-l> which is the readline key binding
for clearing the screen. The following binding can be added to your ~/.tmux.conf file to provide an alternate mapping to clear-screen.
bind C-l send-keys 'C-l'With this enabled you can use <prefix> C-l to clear the screen.
Thanks to [Brian Hogan][] for the tip on how to re-map the clear screen binding.
Troubleshooting
Vim -> Tmux doesn't work!
This is likely due to conflicting key mappings in your ~/.vimrc. You can use
the following search pattern to find conflicting mappings \vn(nore)?map\s+\<c-[hjkl]\>. Any matching lines should be deleted or altered to avoid conflicting
with the mappings from the plugin.
Tmux Can't Tell if Vim Is Active
This functionality requires tmux version 1.8 or higher. You can check your
version to confirm with this shell command:
tmux -V # should return 'tmux 1.8' or higher