/
all.snippets
156 lines (124 loc) · 3.34 KB
/
all.snippets
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Github: https://github.com/Karmenzind/dotfiles-and-scripts
# Last Modified: 2024-01-26 17:20:10
# FIXME (k): <2024年01月25日 星期四 16时19分37秒> leading tabs
global !p
def commented(snip):
b = vim.current.buffer
cms = b.options.get("cms")
if not cms:
return
col = 1
pref = cms % ("" if cms.endswith(" %s") else " ")
for l in range(snip.snippet_start[0], snip.snippet_end[0]+1):
snip.buffer[l] = pref + snip.buffer[l]
col = len(snip.buffer[l])
snip.cursor.set(snip.snippet_end[0], col)
endglobal
###########
# boxes #
###########
post_expand "commented(snip)"
snippet lb "line box"
--------------------------------------------
${1:${VISUAL}}
--------------------------------------------
endsnippet
post_expand "commented(snip)"
snippet llb "long line box"
-----------------------------------------------------------------------------
${1:${VISUAL}}
-----------------------------------------------------------------------------
endsnippet
###########
# abbre #
###########
snippet 192 ".168.0.1"
192.168.0.${1:1}
endsnippet
snippet lh "localhost"
localhost
endsnippet
snippet 127 "localhost"
127.0.0.1
endsnippet
################
# commentary #
################
snippet 44 "line"
--------------------------------------------
endsnippet
snippet 77 "line"
-----------------------------------------------------------------------------
endsnippet
snippet /* "c style block commentary" w
/* ${1:${VISUAL}} */
endsnippet
##############
# identity #
##############
snippet gmail "valesail7" w
valesail7@gmail.com
endsnippet
snippet gh "my github" w
https://github.com/Karmenzind/
endsnippet
snippet ghr "github raw url" w
https://raw.githubusercontent.com/Karmenzind/
endsnippet
snippet kmz "my nickname" w
Karmenzind
endsnippet
##############
# sequence #
##############
global !p
def create_seq(snip):
ph = snip.buffer[snip.line].strip()[1:]
s, e, l = re.match('(\d+)[,-](\d+)[| ](.*)', ph).groups()
body = snip.buffer[snip.line] = ''
s, e = int(s), int(e)
step = 1
if e < s:
e, s = s, e
step = -1
for i in range(s, e):
body += l.format(N=i) + '\n'
snip.expand_anon(body)
endglobal
pre_expand "create_seq(snip)"
snippet "s(\d+[,-]\d+[| ].*\{N\}.*)" "create a seq" br
endsnippet
##########
# test #
##########
# snippet t
# <tag>${VISUAL:inside text/should/is/g}</tag>
# endsnippet
# snippet dt
# `date +%d.%m.%y`
# endsnippet
##########
# mark #
##########
snippet td "todo or other special comments"
${2:TODO} (${1:`!v has("win32")? $USERNAME: $USER`}): <`!v strftime("%Y-%m-%d %H:%M")`> ${0:${VISUAL}}
endsnippet
snippet xxx "XXX or other special comments"
${2:XXX} (${1:`!v has("win32")? $USERNAME: $USER`}): <`!v strftime("%Y-%m-%d %H:%M")`> ${0:${VISUAL}}
endsnippet
snippet fm "FIXME or other special comments"
${2:FIXME} (${1:`!v has("win32")? $USERNAME: $USER`}): <`!v strftime("%Y-%m-%d %H:%M")`> ${0:${VISUAL}}
endsnippet
post_expand "commented(snip)"
snippet trm "to delete" b
These code has been modified or refactored and waiting to be deleted after testing.
此处已经修改或重构,测试稳定后删除原代码
endsnippet
#################
# MyDot Specs #
#################
post_expand "commented(snip)"
snippet mydotheader
Github: https://github.com/Karmenzind/dotfiles-and-scripts
Last Modified: `!v strftime("%Y-%m-%d %T")`
endsnippet