Search code examples
dictionaryvimvim-registers

Copy dictionary to register in Vim


I have a dictionary in my vimrc that I would like to copy and paste into whatever text file I'm editing:

let info = { 'tom':12345, 'bob':54689 }

I tried using put as I would with an option setting but I get an error:

:put=@info

How do I copy the contents of "info" to the register so that I can paste it in my text document?


Solution

  • Try quoting the json data. And removing @ from put command (@ is used to accessed registers, not for variables):

    :let info="{ 'tom':12345, 'bob':54689 }"
    :put=info