-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhardwrap.kak
More file actions
55 lines (50 loc) · 1.38 KB
/
hardwrap.kak
File metadata and controls
55 lines (50 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# The special unicode character is \uE001.
# allows 'jk' to function as <esc>
# hook global WinDisplay .* %{
# hook -group bch_ctrl window InsertChar k %{ try %{
# exec -no-hooks -draft hH <a-k>jk<ret> d
# exec <esc>
# }}
#}
#hook global WinDisplay (.*\.tex|.*\.txt) %{
# # removes above hook
# remove-hooks window bch_ctrl
# hook -group hardwrap window InsertChar [^\s] %{
# try %{ # checks for 'jk' and does <esc> if found.
# exec -no-hooks -draft hH<a-k>jk<ret>d
# exec <esc>
# } catch %{ # otherwise, do dynamic wrap
# hardwrap
# }
# }
#}
hook global WinDisplay (.*\.tex|.*\.txt) %{
# hardwrap-enable
}
def hardwrap-enable %{
hook -group hardwrap window InsertChar [^\n] %{
hardwrap
}
}
def hardwrap-disable %{
remove-hooks window hardwrap
}
def hardwrap %{
exec -no-hooks
exec -no-hooks -draft -itersel "<a-a>pKGls\n<ret>d<a-a>p|fold -s -w 80<ret>"
exec -no-hooks <esc>
exec -no-hooks \%s<ret>
eval -no-hooks -draft -itersel %{
try %{
# trigger catch block if char after is \n
exec -draft l<a-K>\n<ret>
} catch %{
# insert a space after
exec "li <esc>h"
}
}
exec -no-hooks c
# exec -no-hooks d
# exec -no-hooks L|tee<space>-a<space>~/after.txt<ret>h
# exec -no-hooks i
}