vim/tmux: share mapping

This commit is contained in:
Mathieu Maret 2019-09-05 15:38:01 +02:00
parent e933800052
commit 553f83515d
2 changed files with 27 additions and 9 deletions

View File

@ -63,6 +63,21 @@ setw -g monitor-activity on
bind C-j previous-window
bind C-k next-window
#bind -n M-Left select-pane -L
#bind -n M-Right select-pane -R
#bind -n M-Up select-pane -U
#bind -n M-Down select-pane -D
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
bind -n M-Up if "[ $(tmux display -p '#{pane_current_command}') = vim ]" "send-keys M-Up" "select-pane -U"
bind -n M-Down if "[ $(tmux display -p '#{pane_current_command}') = vim ]" "send-keys M-Down" "select-pane -D"
bind -n M-Left if "[ $(tmux display -p '#{pane_current_command}') = vim ]" "send-keys M-Left" "select-pane -L"
bind -n M-Right if "[ $(tmux display -p '#{pane_current_command}') = vim ]" "send-keys M-Right" "select-pane -R"
bind -n C-Right if "[ $(tmux display -p '#{pane_current_command}') = vim ]" "send-keys C-Right" "next-window"
bind -n C-Left if "[ $(tmux display -p '#{pane_current_command}') = vim ]" "send-keys C-Right" "previous-window"
#set-option -g status-utf8 on
set-option -g status-justify left
set-option -g status-bg black

21
.vimrc
View File

@ -289,15 +289,15 @@ set splitright
" if multiple windows
if bufwinnr(1)
" vertically increase/decrease window size with alt+up/alt+down
map <M-Up> <C-W>+
map <M-Down> <C-W>-
imap <M-Up> <ESC><M-Up>a
imap <M-Down> <ESC><M-Down>a
" horizontally increase/decrease window size with alt+right/alt+left
map <M-Right> <C-W>>
map <M-Left> <C-W><
imap <M-Right> <ESC><M-Right>a
imap <M-Left> <ESC><M-Left>a
nnoremap <M-Up> :TmuxNavigateUp<cr>
nnoremap <M-Right> :TmuxNavigateRight<cr>
imap <M-Up> <ESC>:TmuxNavigateUp<cr>
imap <M-Right> <ESC>:TmuxNavigateRight<cr>
" " horizontally increase/decrease window size with alt+right/alt+left
nnoremap <M-Left> :TmuxNavigateLeft<cr>
nnoremap <M-Down> :TmuxNavigateDown<cr>
imap <M-Left> <ESC>:TmuxNavigateLeft<cr>
imap <M-Down> <ESC>:TmuxNavigateDown<cr>
" switch to next/previous tab with ctrl+right/ctrl+left
map <C-Right> gt
map <C-Left> gT
@ -636,4 +636,7 @@ let g:polyglot_disabled = ['latex']
" Visual incrementation. increment in block with ctrl-A
Plugin 'triglav/vim-visual-increment'
set nrformats=alpha,octal,hex
Plugin 'christoomey/vim-tmux-navigator'
let g:tmux_navigator_no_mappings=1
call vundle#end()