# arrow keys for completions declare-option -hidden str completions_status 'completions-off' define-command -hidden completions-off fail define-command -hidden completions-on nop define-command -hidden completions-up nop define-command -hidden completions-down fail hook global InsertCompletionShow .* %{ set-option window completions_status 'completions-on' } hook global InsertCompletionHide .* %{ set-option window completions_status 'completions-off' } define-command -hidden assert-completions %{ %opt{completions_status} } # arg: "completions-up" or "completions-down" define-command -hidden -params 1 move-or-complete %{ try %{ # completions are visible %opt{completions_status} try %{ # up %arg{1} execute-keys } catch %{ # down execute-keys } } catch %{ # completions are not visible try %{ # up %arg{1} execute-keys } catch %{ execute-keys } } } map global insert ': move-or-complete completions-down' map global insert ': move-or-complete completions-up' map global insert map global insert map global insert map global insert map global insert "[p" map global insert "]p" map global insert ": write" # indentation map global insert map global insert map global insert map global insert # word movement (based version) map global insert b map global insert b map global insert w map global insert w map global insert e map global insert "[p" map global insert "]p" define-command -hidden insert-char-no-hook %{ execute-keys '\i' hook -always -once window InsertChar .* %{ execute-keys '' } } define-command -hidden insert-no-hook %{ execute-keys '\i' } map global insert ': insert-char-no-hook' map global insert ': insert-no-hook'