Skip to content

Instantly share code, notes, and snippets.

@natsukagami
Created March 1, 2020 05:39
Show Gist options
  • Save natsukagami/d07aced63cdc14b88af408f9b913dd20 to your computer and use it in GitHub Desktop.
Save natsukagami/d07aced63cdc14b88af408f9b913dd20 to your computer and use it in GitHub Desktop.
hook global WinSetOption filetype=(latex) %{
map window normal $ "i\(\)<esc>hhi"
map window normal <a-4> "i\[\]<esc>hhi"
# hook window InsertChar @ %{
# }
hook window InsertChar / %{
try %{
execute-keys -draft "hb<a-k>\)<ret>mZ;c\frac{<esc>z<a-:>;Lc}{}<esc>"
execute-keys "<a-;>h"
} catch %{
try %{
execute-keys -draft "hb;F/<a-K>(\s|^)/<ret>i\frac{<esc><a-:>;c}{}<esc>"
execute-keys "<a-;>h"
}
}
}
hook window InsertChar \d %{
try %{
execute-keys -draft "h2H<a-k>_\d\d<ret>Lc{<esc>Pi}<esc>"
execute-keys "<a-;>h"
} catch %{
try %{
execute-keys -draft "hH<a-k>[a-zA-Z]\d<ret>Li_<esc>"
}
}
}
define-command -hidden go-to-dollar-zero %{
execute-keys "<esc>/\$0<ret>c"
unmap window insert <tab> "<a-;>: go-to-dollar-zero<ret>"
}
hook window InsertCompletionHide .* %{
try %{
execute-keys -draft "KK<a-x><a-k>^\\begin\{\$1\}<ret>"
execute-keys "<esc>KK<a-x>s\$1<ret>c<a-;>"
map window insert <tab> "<a-;>: go-to-dollar-zero<ret>"
hook window -once ModeChange .*ormal.* %{
unmap window insert <tab> "<a-;>: go-to-dollar-zero<ret>"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment