Giter VIP home page Giter VIP logo

vim-yamsong's Introduction

Use vim to Edit JSON as YAML

YAML is a superset of JSON :-)

In general YAML is easier to edit then JSON.

  • It's more forgiving of formatting
  • No need for quoting every attribute and value

In short, YAML is meant to be written by hand, JSON by programs. But it's not uncommon to create and edit JSON files by hand, often to configure other applications. This plugin helps me in that task. FWIW, my particular driver was JSON config for projectionist, but I believe this to be more generally useful.

It exposes a single command in a JSON file, EditAsyaml which:

  • opens a memory only vertical split with a YAML version of the JSON
  • Allows toggling between YAML and JSON versions
  • Set's vim diff view against the original when the scratch buffer is in JSON mode
  • Allows writeback to the original buffer (via FileWriteCmd events).

Caveats

It uses a short bit of python3 to do the heavy lifting. This is external (and bundled in the plugin) to minimize (but not entirely avoid) dependencies. Vim's support for JSON is solid, but YAML support is not vim's strength.

Python 3 is quite common install, likely to be present on many systems, even those where vim does not have formal python3 support. That said, I'm looking for alternatives.

The end JSON is normalized by alphabatizing keys. This eases the job of translation, but it could conceivably effect carefully hand crafted ordering.

vim-yamsong's People

Contributors

fourjay avatar junkblocker avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

junkblocker

vim-yamsong's Issues

Sorting by key

I am a newbie and I tried this plugin very recently. The plugin sorts the JSON by key, per this commit. I have read that Python dicts are ordered since 3.7. Is it possible that the commit pre-dates Python 3.7 and might now be unnecessary?

Dependencies

Thank you for the plugin. I am a Vim newbie. I needed to do these:

  1. install PYYaml, which on Debian is the package python3-yaml, and
  2. add filetype indent plugin on to the vimrc.
    2.1. I tried filetype plugin on and it seems enough, but I'm not sure the indent part is enabling functionality in this plugin?

Without filetype ... on, it does work to :call yamsong#split() manually, but :EditAsyaml gives error "Not an editor command".

I spent a few hours googling and asking for help to find these solutions. I think that documenting them in the README would help another newbies that want to try the plugin.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.