История изменений
Исправление Difrex, (текущая версия) :
Так что если кто знает что-то кроме плагина к vim тоже пишите кто чем пользуется
yaml-mode.
Вот тебе форматтер:
#!/usr/bin/python
import yaml
import sys
if len(sys.argv) < 2:
print("Usage: " + sys.argv[0] + " <file.yml>")
sys.exit(2)
f = sys.argv[1]
y = None
with open(f, "r") as yf:
y = yf.read()
yd = yaml.load(y)
yf = yaml.dump(yd)
with open(f, "w") as yw:
yw.write(yf)
test.yaml
some_hashmap:
one:
- two
- three
two:
three:
four:
- five
- 6
vars_list:
- one
- two
some_dict: {foo: {bar: ["baz"]}}
./yaml-formatter.py test.yaml
some_dict:
foo:
bar: [baz]
some_hashmap:
one: [two, three]
two:
three:
four: [five, 6]
vars_list: [one, two]
Исходная версия Difrex, :
Так что если кто знает что-то кроме плагина к vim тоже пишите кто чем пользуется
yaml-mode.
Вот тебе форматтер:
#!/usr/bin/python
import yaml
import sys
if len(sys.argv) < 2:
print("Usage: " + sys.argv[0] + " <file.yml>")
sys.exit(2)
f = sys.argv[1]
y = None
with open(f, "r") as yf:
y = yf.read()
yd = yaml.load(y)
yf = yaml.dump(yd)
with open(f, "w") as yw:
yw.write(yf)
test.yaml
vars_list: ["one", "two"]
some_hashmap:
one:
- two
- three
two:
three:
four:
- "five"
- 6
./yaml-formatter.py test.yaml
some_hashmap:
one: [two, three]
two:
three:
four: [five, 6]
vars_list: [one, two]