Questions tagged [dictionary]

Questions relating to the 'dictionary' or 'dict' setting.

Filter by
Sorted by
Tagged with
0 votes
1 answer
58 views

Default value for non existing keys in dictionaries

Is there a way to return a default value if a key is not present in a dictionary? For example, say that I have mydict = {'foo':1, 'bar': 2}. I want that if I call e.g. :echo mydict['apple'] I get a ...
Barzi2001's user avatar
  • 508
0 votes
1 answer
80 views

Adding dictionary words list to deoplete plugin

Let's say I have a list of words in one file in my home directory (each word is in a separate line): bar barfoo foo foobar ... How can I add this list of words to Vim deoplete auto-completion plugin? ...
C_Note's user avatar
  • 1
0 votes
1 answer
35 views

ctrl-x, ctrl-k spelling completion not working on Windows

I use the same configuration on Linux and Windows. This is the config for spelling: " Set dictionary and regenerate spl files on startup set dictionary+=/usr/share/dict/words set spelllang=en_gb ...
paradroid's user avatar
  • 367
1 vote
1 answer
458 views

How to autocomplete from dictionary while typing?

I've set a dictionary with the command: set dictionary+=~/Dictionary.txt And add the following command to make more quickly to access it: set complete+=k But I still have to press <CTRL-N> to ...
rpmeira's user avatar
  • 43
0 votes
1 answer
103 views

How to get the union/merge of dictionaries? [duplicate]

I'd like to combine two nested dictionaries following these rules: if value is not a dictionary, override the key in resulting dictionary if value is a dictionary, compute union of the two. Example: ...
listboss's user avatar
  • 101
1 vote
0 answers
585 views

E716: Key not present in dictionary: "3"

I have this global at the top of my .vimrc: let DevEnv = { 'enabled' : 0, 'open_dirs' : 0, 'term_bufnr' : 0 } One of my .vimrc functions calls: exec 'bd! ' . g:DevEnv.term_bufnr Note that g:DevEnv....
daedsidog's user avatar
  • 153
2 votes
1 answer
337 views

How do I put the List returned from a 'heredoc' (:h Let-HereDocs) into a Dictionary in Vim? How do I also make this work in Neovim?

In :help let-heredoc it explains that one can set a variable to a 'heredoc' where each line of the heredoc becomes an entry in a list as follows: let text =<< trim END if ok echo 'done' ...
Incalculon's user avatar
0 votes
0 answers
45 views

navigating dictionary completion

In my vimrc I have the following mappings: set completeopt=longest,menuone,preview inoremap <C-h> <C-n> inoremap <C-k> <C-p> inoremap <Leader>k <C-x><C-k&...
myc3lium's user avatar
4 votes
1 answer
172 views

What is the #{} syntax in Vim?

I just noticed this in a Vim help page: popup_beval(s:balloonText, #{mousemoved: 'word'}) What is the #{mousemoved: 'word'}? It looks like a dict? I tried using :help #{, but that doesn't show any ...
Martin Tournoij's user avatar
16 votes
1 answer
2k views

How can I merge two dictionaries in Vim?

I have two dicts: :let defaults = {'hello': 'world', 'bye': 'jupiter'} :let override = {'hello': 'mars'} How can I merge the keys from override so that I end up with a new dict like so: {'hello': '...
Martin Tournoij's user avatar
8 votes
2 answers
2k views

How can I tell vim to ignore spelling errors inside quotes?

If I'm editing a text file with :set spell, is there any way to have vim not check words within the boundaries of certain characters against the word list? I want to be able to write things like ...
myc3lium's user avatar
  • 101
2 votes
0 answers
48 views

How to omit dictionary source file in dictionary completion

<C-X><C-K> complete words with long dictionary file name, such as /home/xxx/.vim/mydict. I'd like to omit or shorten the descriptive info. I have googled but got no hints. Any advice?
asepsiswu's user avatar
4 votes
2 answers
326 views

Is there a Set datatype in VimScript?

I am aware of lists and dictionaries in Vim. But are sets supported in Vim to store only unique values? Or do I just have to use a dictionary with some dummy value?
HariUserX's user avatar
  • 143
1 vote
2 answers
2k views

How to get the specific key in a dictionary using the just the key's value?

Suppose I have a dictionary declared like this: g:dict = { \ 'foo' : ['foobar'], \ 'bar' : ['barfoo'] \} how can I get the key for barfoo using just the value(barfoo) itself?
John Fred Fadrigalan's user avatar
3 votes
2 answers
2k views

How to enable dictionary autocompletion without spell option set

I noticed, that in any source code file, regardless of the programming language, I can use the dictionary autocompletion (Ctrl + x Ctrl+k) if the spell option is set, if it's not, then the editor ...
d.k's user avatar
  • 650
0 votes
3 answers
2k views

Can add() and insert() be performed on a dictionary?

Can add() and insert() be performed on a dictionary? The help file is unclear on this. If so, what is the correct syntax? If these functions do not work on dictionaries, then how can I add or insert ...
Tyler Durden's user avatar
  • 2,091
1 vote
2 answers
1k views

Filter dict items using list of keys

Give the following dictionary: let mydict = {'foo': {'a': 1, 'b': 2}, 'bar': {'c': 3, 'd': 4}} And a list of keys: let myfilter = ['foo', 'asdf'] How would one do a concise "left outer join (if ...
timss's user avatar
  • 291
8 votes
1 answer
274 views

When using the dictionary feature in vim, can you make dashes a matching part of a word?

The dictionary feature in vim allows you to use a file (for instance /usr/share/dict/words) and set multiple paths within the dict option to search on. Now the file I'm searching on has several ...
leeand00's user avatar
  • 3,491