diff --git a/README.md b/README.md index 9977f8d..922e76c 100644 --- a/README.md +++ b/README.md @@ -208,7 +208,7 @@ of plugins above to learn more. #### Tabs, Windows, Splits * Use `Cmd-1` thru `Cmd-9` to switch to a specific tab number (like iTerm and Chrome) - and tabs have been set up to show numbers (`Alt` in Linux) - * `Ctrl-h,l,j,k` - to move left, right, down, up between splits + * `Ctrl-h,l,j,k` - to move left, right, down, up between splits. This also works between vim and tmux splits thanks to `vim-tmux-navigator`. * `Q` - Intelligent Window Killer. Close window `wincmd c` if there are multiple windows to same buffer, or kill the buffer `bwipeout` if this is the last window into it. * `vv` - vertical split (`Ctrl-w,v`) * `ss` - horizontal split (`Ctrl-w,s`) diff --git a/doc/vim/navigation.md b/doc/vim/navigation.md index 8476baa..740b061 100644 --- a/doc/vim/navigation.md +++ b/doc/vim/navigation.md @@ -6,3 +6,4 @@ * CtrlP - ,t to find a file * Visual-star-search - make the * (star) search in visual mode behave like expected: searching for the whole selection instead of just the word under the cursor. * Ag - super fast search by Silver Searcher. hit `K` to grep current word +* vim-tmux-navigator - nagivate between vim and tmux splits in the same way you move between normal vim splits. diff --git a/tmux/tmux.conf b/tmux/tmux.conf index 81438aa..dc156d5 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -20,6 +20,15 @@ bind -r J resize-pane -D 5 bind -r K resize-pane -U 5 bind -r L resize-pane -R 5 +# Smart pane switching with awareness of vim splits. +# Source: https://github.com/christoomey/vim-tmux-navigator +bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys C-h) || tmux select-pane -L" +bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys C-j) || tmux select-pane -D" +bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys C-k) || tmux select-pane -U" +bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys C-l) || tmux select-pane -R" +# Conflicts with Nerdtree binding. Can possibly add back later under a different alias. +#bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys 'C-\\') || tmux select-pane -l" + # Use vi keybindings for tmux commandline input. # Note that to get command mode you need to hit ESC twice... set -g status-keys vi diff --git a/vim/vundles/vim-improvements.vundle b/vim/vundles/vim-improvements.vundle index 6b162ab..33d75f1 100644 --- a/vim/vundles/vim-improvements.vundle +++ b/vim/vundles/vim-improvements.vundle @@ -9,6 +9,7 @@ Bundle "vim-scripts/matchit.zip.git" Bundle "terryma/vim-multiple-cursors" Bundle "Keithbsmiley/investigate.vim" Bundle "chrisbra/NrrwRgn" +Bundle "christoomey/vim-tmux-navigator" Bundle "MarcWeber/vim-addon-mw-utils.git" Bundle "bogado/file-line.git" Bundle "mattn/webapi-vim.git"