Linux Today: Linux News On Internet Time.

More on LinuxToday

Scripting the Vim editor, Part 4: Dictionaries

Feb 17, 2010, 20:33 (0 Talkback[s])
(Other stories by Damian Conway)


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

"A dictionary is a container data structure that offers different optimizations and trade-offs from a list. In particular, in a dictionary the order of the elements stored is irrelevant and the identity of each element is explicit. In this fourth article in a series introducing Vimscript, Damian Conway introduces you to dictionaries, including an overview of their basic syntax and many functions. He concludes with several examples that illustrate the use of dictionaries for more efficient data processing and cleaner code.

"A dictionary in Vimscript is essentially the same as an AWK associative array, a Perl hash, or a Python dictionary. That is, it's an unordered container, indexed by strings rather than integers.

"This fourth article in a series on Vimscript introduces this important data structure and explains its various functions for copying, filtering, extending, and pruning. The examples focus on the differences between lists and dictionaries, and on those cases where the use of a dictionary is a better alternative to the list-based solutions developed in Part 3 on built-in lists."

Complete Story

Related Stories: