diff --git a/vim/.vimrc b/vim/.vimrc new file mode 100644 index 0000000..bb8de90 --- /dev/null +++ b/vim/.vimrc @@ -0,0 +1,25 @@ +" Tmux integration to switch panes with Ctrl+{hjkl} +if exists('$TMUX') + function! TmuxOrSplitSwitch(wincmd, tmuxdir) + let previous_winnr = winnr() + silent! execute "wincmd " . a:wincmd + if previous_winnr == winnr() + call system("tmux select-pane -" . a:tmuxdir) + redraw! + endif + endfunction + + let previous_title = substitute(system("tmux display-message -p '#{pane_title}'"), '\n', '', '') + let &t_ti = "\2;vim\\\" . &t_ti + let &t_te = "\2;". previous_title . "\\\" . &t_te + + nnoremap :call TmuxOrSplitSwitch('h', 'L') + nnoremap :call TmuxOrSplitSwitch('j', 'D') + nnoremap :call TmuxOrSplitSwitch('k', 'U') + nnoremap :call TmuxOrSplitSwitch('l', 'R') +else + map h + map j + map k + map l +endif \ No newline at end of file