Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim displays json file without any quotes

I have a validated json file that will display without any quotes in Vim. The only time it displays the json file correctly is under Visual mode.

I have tried disabling eslint, jshint, youcompleteme

OS X MacVim 7.4 Vim 7.4 in Terminal

enter image description here

enter image description here

like image 387
Joel Z. Avatar asked Nov 15 '16 04:11

Joel Z.


3 Answers

The built-in $VIMRUNTIME/syntax/json.vim uses Vim's conceal feature to hide the quotes, presumably to remove unnecessary clutter.

You must have enabled concealing by setting the 'conceallevel' option to 2 or 3; the default is 0 (off). Likewise, you see the quotes in visual mode because of your 'concealcursor' setting.

Inside a JSON file, check where the conceal options got set:

:verbose set conceallevel? concealcursor?

Then, you can adapt your settings to suit your preferences.

like image 65
Ingo Karkat Avatar answered Nov 18 '22 11:11

Ingo Karkat


Adding to the currently accepted answer, you can disable that behavior specifically for JSON by setting the following option in you .vimrc:

" Disable quote concealing in JSON files
let g:vim_json_conceal=0

That way, you don't have to set conceallevel to 0 (disabled), which would also make useful plugins like indentLine (which was mentioned in a comment above) not work anymore.

like image 25
Maxr1998 Avatar answered Nov 18 '22 10:11

Maxr1998


Like already mentioned, one can check which plugin caused the increased conceal level:

:verbose set conceallevel?

If the conceal level is caused by the vim-json Plugin:

let g:vim_json_syntax_conceal = 0

If conceal is caused by the indentLine Plugin:

let g:indentLine_setConceal = 0

In vimrc, You can add both options for json files:

autocmd Filetype json
  \ let g:indentLine_setConceal = 0 |
  \ let g:vim_json_syntax_conceal = 0
like image 15
user8162 Avatar answered Nov 18 '22 12:11

user8162