I have this in my vimrc according to ":h xterm-focus-event":

    if &term =~ '\v^(screen|tmux)'
      let &t_fe = "\<Esc>[?1004h"
      let &t_fd = "\<Esc>[?1004l"
    endif

With it in tmux, when I switch panes, the pane with Vim running shows a
control sequence "^[[O" where "^[" is Esc.  I had to add this autocmd to
circumvent this:

    if &term =~ '\v^(screen|tmux)'
      augroup autoread
        au!
        au FocusLost * :redraw!
      augroup END
    endif

It works well enough in local machine, but over ssh, it causes annoying
flickering.  Did anyone face this before (or does now) and solved it?


In .tmux.conf, I have:

    set -g escape-time 10           # wait 10ms after Esc key
    set -g repeat-time 500          # wait 100ms for repeating command
    set -g focus-events on
    set -g set-clipboard on
    set -g history-limit 5000

    set -g default-terminal "tmux-256color"
    set -ga terminal-overrides ',xterm-256color*:Tc'
    set -as terminal-overrides ',st-256color:Ms=\E]52;%p1%s;%p2%s\007'
    set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q'

    is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
        | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"

    bind-key -n C-h   if-shell  "$is_vim"  "send-keys C-h"  "select-pane -L"
    bind-key -n C-j   if-shell  "$is_vim"  "send-keys C-j"  "select-pane -D"
    bind-key -n C-k   if-shell  "$is_vim"  "send-keys C-k"  "select-pane -U"
    bind-key -n C-l   if-shell  "$is_vim"  "send-keys C-l"  "select-pane -R"
    bind-key -n C-\   if-shell  "$is_vim"  "send-keys C-\\" "select-pane -l"

The later part of the tmux config lets me switch tmux panes and vim
splits with the same keys.  The if-shell syntax is straight-forward but
let me know if it's confusing and I can explain.

The versions of Vim and Tmux I'm using is postscripted.

--
Enan

$ tmux -V
tmux 3.2a

$ vim --version
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Apr 14 2023 03:28:41)
Included patches: 1-1403
Modified by <amazon-linux-eng...@amazon.com>
Compiled by <amazon-linux-eng...@amazon.com>
Huge version without GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
+arabic            +find_in_path      +mouse_xterm       -tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
-balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +gettext           +num64             +textobjects
-browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     +perl/dyn          +title
+channel           +ipv6              +persistent_undo   -toolbar
+cindent           +job               +popupwin          +user_commands
-clientserver      +jumplist          +postscript        +vartabs
-clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +vim9script
+cmdline_hist      +langmap           -python            +viminfo
+cmdline_info      +libcall           +python3/dyn       +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          +rightleft         +vreplace
+cscope            +localmap          +ruby/dyn          +wildignore
+cursorbind        +lua/dyn           +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con        +mksession         +smartindent       +writebackup
+diff              +modify_fname      -sodium            -X11
+digraphs          +mouse             -sound             -xfontset
-dnd               -mouseshape        +spell             -xim
-ebcdic            +mouse_dec         +startuptime       -xpm
+emacs_tags        +mouse_gpm         +statusline        -xsmp
+eval              -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +tag_binary
-farsi             -mouse_sysmouse    -tag_old_static
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -g -pipe -Wall -fexceptions 
-fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 
-mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DSYS_VIMRC_FILE=/etc/vimrc 
-D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,--enable-new-dtags -Wl,-rpath,/usr/lib64/perl5/CORE 
-Wl,-z,relro -L/usr/local/lib -Wl,--as-needed -o vim -lm -lselinux -lncurses 
-lrt -lacl -lattr -lgpm -ldl -Wl,--enable-new-dtags 
-Wl,-rpath,/usr/lib64/perl5/CORE -fstack-protector -L/usr/lib64/perl5/CORE 
-lperl -lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/20230619222021.0000342a%40gmail.com.

Reply via email to