ディクショナリの一括変換
作者: 小見 拓
—
最終変更
2012年01月08日 12時08分
ディクショナリの一括変換
- ディクショナリの各キーは「v:key」に、各値は「v:val」に入る。
:let var_dict = { "one":"item 1", "two":"item 2", "three":"item 3", "four":"item 4" } :echo map(var_dict, "'key is ' . v:key . ' value is ' . v:val") "# => {'four': 'key is four value is item 4', 'one': 'key is one value is item 1', 'two': 'key is two value is item 2', 'three': 'key is three value is item 3'} :let var_dict = { "one":"item 1", "two":"item 2", "three":"item 3", "four":"item 4" } :echo map(var_dict, "v:key =~ '^t' ? 'XXXX' : v:val") "# => {'four': 'item 4', 'one': 'item 1', 'two': 'XXXX', 'three': 'XXXX'}