Replace the numbered prefix to more detailed items.
Before:
After:
How is this done?
import json
with open("snippets.json") as f:
snippets = json.load(f)
another_dict = {}
for k,v in snippets.items():
# print(k,"_".join(v["description"].split()))
concated = "_".join(v["description"].split())
if not concated in snippets:
if not concated in another_dict:
another_dict[concated] = v.copy()
another_dict[concated]["prefix"] = concated
else:
print(concated, v)
else:
another_dict[k] = v.copy()
# output:
# keyPressed {'prefix': 'key', 'body': 'void keyPressed() {\n\t${1}\n}', 'description': 'keyPressed', 'scope': 'source.pde'}
# mousePressed {'prefix': 'mouse', 'body': 'void mousePressed() {\n\t${1}\n}', 'description': 'mousePressed', 'scope': 'source.pde'}
# These two have duplicated var name and method, so add the `_func` postfix for method.
with open('edited.json','w') as f:
json.dump(another_dict, f)
Replace the numbered prefix to more detailed items.
Before: After:
How is this done?