provide-module surround %~ declare-user-mode surround declare-user-mode surround-add define-command -override surround-add-pair -params 2 %{ evaluate-commands -draft -save-regs '"' %{ set-register '"' %arg{1} execute-keys -draft P set-register '"' %arg{2} execute-keys -draft p } } # command surrounds with any arbitrary character define-command -override -hidden surround-add-key -params 1 %{ evaluate-commands -draft -save-regs '"' %{ set-register '"' %arg{1} execute-keys -draft P execute-keys -draft p } } define-command surround-add %{ info -title surround "Enter character to add" on-key %{ eval %sh{ if [ "$kak_key" != "" ]; then printf '%s' 'surround-add-key %val{key}' else printf '%s' 'info -title surround "Canceled"' fi } } } define-command -hidden surround-delete-key -params 1 %{ execute-keys -draft "%arg{1}ia" } define-command surround-delete %{ info -title surround "Enter character to delete" on-key %{ eval %sh{ if [ "$kak_key" != "" ]; then printf '%s' 'surround-delete-key %val{key}' else printf '%s' 'info -title surround "Canceled"' fi } } } define-command -hidden surround-replace-sub -params 1 %{ info -title surround "Enter character to replace with" on-key %{ eval %sh{ if [ "$kak_key" != "" ]; then printf '%s' 'evaluate-commands -no-hooks -draft %{ execute-keys "%arg{1}" enter-user-mode surround-add execute-keys %val{key} } surround-delete-key %arg{1} execute-keys H' else printf '%s' 'info -title surround "Canceled"' fi } } } define-command surround-replace %{ info -title surround "Enter character to replace" on-key %{ eval %sh{ if [ "$kak_key" != "" ]; then printf '%s' 'surround-replace-sub %val{key}' else printf '%s' 'info -title surround "Canceled"' fi } } } map global surround-add ( ':surround-add-pair ( )' -docstring 'surround with parenthesis' map global surround-add ) ':surround-add-pair ( )' -docstring 'surround with parenthesis' map global surround-add [ ':surround-add-pair [ ]' -docstring 'surround with brackets' map global surround-add ] ':surround-add-pair [ ]' -docstring 'surround with brackets' map global surround-add { ':surround-add-pair { }' -docstring 'surround with braces' map global surround-add } ':surround-add-pair { }' -docstring 'surround with braces' map global surround-add < ':surround-add-pair ' -docstring 'surround with angles' map global surround-add > ':surround-add-pair ' -docstring 'surround with angles' map global surround-add "'" ":surround-add-pair ""'"" ""'""" -docstring 'surround with quotes' map global surround-add '"' ":surround-add-pair '""' '""'" -docstring 'surround with double quotes' map global surround-add * ':surround-add-pair * *' -docstring 'surround with asteriks' map global surround-add _ ':surround-add-pair _ _' -docstring 'surround with undescores' map global surround-add s ':surround-add' -docstring 'surround custom character' map -docstring 'surround' global normal k ': enter-user-mode surround' map -docstring 'add surrounding' global surround s ': enter-user-mode surround-add' map -docstring 'delete surrounding' global surround d ':surround-delete' map -docstring 'replace surrounding' global surround r ':surround-replace' map -docstring 'select inside object' global surround i '' map -docstring 'select around object' global surround a '' ~