tmux: Fix C-e & C-y bindings

Apparently I broke them in commit 4e8ab80c66 ("tmux: Fix edge cases
in paragraph text-object") by adding the comments. Through them the
bindings were not set in place since the binding stopped with the
comment (I guess?). Weirdly I do not get an error message and the
default bindings stay, so I am not sure what exactly happens. This could
also be due to a version change from 3.3a to 3.4.

Fix the bindings by starting a code block instead of just escaping the
newline.

Do this also everywhere else to prevent errors in the future.
This commit is contained in:
2024-09-15 22:44:52 +02:00
parent 29e6b46135
commit c6b317f794

View File

@@ -63,7 +63,7 @@ bind -n TripleClick1Pane {
# when the current pane is in alternate mode and discard the `-e` flag passed to # when the current pane is in alternate mode and discard the `-e` flag passed to
# copy-mode from the default binding (See below) # copy-mode from the default binding (See below)
# TODO: Do not modify selection when scolling with the wheel # TODO: Do not modify selection when scolling with the wheel
bind -n WheelUpPane \ bind -n WheelUpPane {
if -F "#{||:#{pane_in_mode},#{mouse_any_flag}}" { if -F "#{||:#{pane_in_mode},#{mouse_any_flag}}" {
send -M send -M
} { } {
@@ -73,16 +73,18 @@ bind -n WheelUpPane \
copy-mode; send -XN5 scroll-up copy-mode; send -XN5 scroll-up
} }
} }
}
# Scroll without selecting the pane # Scroll without selecting the pane
bind -T copy-mode-vi WheelUpPane send -XN5 scroll-up bind -T copy-mode-vi WheelUpPane send -XN5 scroll-up
# Exit copy-mode when at the bottom. This practically mimics `copy-mode -e` but # Exit copy-mode when at the bottom. This practically mimics `copy-mode -e` but
# only scrolling with the wheel (`-e` annoys me when scrolling down with `C-d`). # only scrolling with the wheel (`-e` annoys me when scrolling down with `C-d`).
bind -T copy-mode-vi WheelDownPane \ bind -T copy-mode-vi WheelDownPane {
if -F "#{==:0,#{scroll_position}}" { if -F "#{==:0,#{scroll_position}}" {
send -X cancel send -X cancel
} { } {
send -XN5 scroll-down send -XN5 scroll-down
} }
}
# Split panes with > and < # Split panes with > and <
unbind % unbind %
@@ -132,12 +134,13 @@ bind -r P swap-window -d -t :-1
bind -n MouseDrag1Status swap-window -d -t= bind -n MouseDrag1Status swap-window -d -t=
# TODO: do nothing on drags that don't start on a window name # TODO: do nothing on drags that don't start on a window name
bind -n MouseDragEnd1StatusDefault \ bind -n MouseDragEnd1StatusDefault {
if -F "#{e|>|f|0:#{mouse_x},#{e|/|f:#{window_width},2}}" { if -F "#{e|>|f|0:#{mouse_x},#{e|/|f:#{window_width},2}}" {
run-shell "tmux move-window -at #{last_window_index}" run-shell "tmux move-window -at #{last_window_index}"
} { } {
move-window -t0 move-window -t0
} }
}
# Repeatable window-movement bindings # Repeatable window-movement bindings
bind -r \{ swap-pane -U bind -r \{ swap-pane -U
@@ -173,20 +176,22 @@ bind -T copy-mode-vi C-v {
# Yank into system clipboard with vim-like bindings # Yank into system clipboard with vim-like bindings
bind -T copy-mode-vi y run-shell '${XDG_CONFIG_HOME:-$HOME/.config}/tmux/yank.sh' bind -T copy-mode-vi y run-shell '${XDG_CONFIG_HOME:-$HOME/.config}/tmux/yank.sh'
bind -T copy-mode-vi Y \ bind -T copy-mode-vi Y {
if -F "#{selection_present}" { if -F "#{selection_present}" {
send -X copy-pipe-line send -X copy-pipe-line
} { } {
send -X copy-pipe-end-of-line send -X copy-pipe-end-of-line
} }
}
# Clear selection or cancel copy-mode when nothing is selected # Clear selection or cancel copy-mode when nothing is selected
bind -T copy-mode-vi Escape \ bind -T copy-mode-vi Escape {
if -F "#{selection_present}" { if -F "#{selection_present}" {
send -X clear-selection send -X clear-selection
} { } {
send -X cancel send -X cancel
} }
}
# Use insert-mode-like bindings to cancel copy-mode # Use insert-mode-like bindings to cancel copy-mode
bind -T copy-mode-vi A send -X cancel bind -T copy-mode-vi A send -X cancel
@@ -200,7 +205,7 @@ bind -T copy-mode-vi i run-shell '${XDG_CONFIG_HOME:-$HOME/.config}/tmux/textobj
# cannot scroll past the first and last history line, both bindings stop # cannot scroll past the first and last history line, both bindings stop
# scrolling when the respective line is visible. This mimics the behaviour of # scrolling when the respective line is visible. This mimics the behaviour of
# vim's C-y at the top of the file. # vim's C-y at the top of the file.
bind -T copy-mode-vi C-e \ bind -T copy-mode-vi C-e {
# check that there is still history beneath to scroll to. # check that there is still history beneath to scroll to.
if -F "#{e|>:#{scroll_position},0}" { if -F "#{e|>:#{scroll_position},0}" {
send-keys -X scroll-down send-keys -X scroll-down
@@ -209,8 +214,9 @@ bind -T copy-mode-vi C-e \
send-keys -X cursor-up send-keys -X cursor-up
} }
} }
}
bind -T copy-mode-vi C-y \ bind -T copy-mode-vi C-y {
# check that there is still history above to scroll to. # check that there is still history above to scroll to.
if -F "#{e|<:#{scroll_position},#{history_size}}" { if -F "#{e|<:#{scroll_position},#{history_size}}" {
send-keys -X scroll-up send-keys -X scroll-up
@@ -219,6 +225,7 @@ bind -T copy-mode-vi C-y \
send-keys -X cursor-down send-keys -X cursor-down
} }
} }
}
# Navigate panes with <prefix>-[hjkl] # Navigate panes with <prefix>-[hjkl]
# NOTE: C-[hjkl] (w/o prefix) moves through vim splits and tmux panes # NOTE: C-[hjkl] (w/o prefix) moves through vim splits and tmux panes