November 2018
Beginner
330 pages
7h 21m
English
Dictionaries are also supported in Vim:
let animal_names = { \ 'cat': 'Miss Cattington', \ 'dog': 'Mr Dogson', \ 'parrot': 'Polly' \ }
As you may have noticed, you need to explicitly outline the line breaks with a backslash \ if you're defining a dictionary on multiple lines.
Dictionary modification operations are similar to the ones familiar to you from Python. Elements can be accessed in two ways:
let cat_name = animal_names['cat'] " get an elementlet cat_name = animal_names.cat " another way to access an element
Accessing an element via . only works if the key contains numbers, letters, and underscores.
You can set or override a dictionary entry as follows:
let animal_names['raven'] = 'Raven R. Raventon'
Entries are removed ...
Read now
Unlock full access