GithubHelp home page GithubHelp logo

vim-jdaddy's Introduction

jdaddy.vim

Check out these must have mappings for working with JSON in Vim:

  • aj provides a text object for the outermost JSON object, array, string, number, or keyword.
  • gqaj "pretty prints" (wraps/indents/sorts keys/otherwise cleans up) the JSON construct under the cursor.
  • gwaj takes the JSON object on the clipboard and extends it into the JSON object under the cursor.

There are also ij variants that target innermost rather than outermost JSON construct.

Installation

If you don't have a preferred installation method, I recommend installing pathogen.vim, and then simply copy and paste:

cd ~/.vim/bundle
git clone git://github.com/tpope/vim-jdaddy.git

Self-Promotion

Like jdaddy.vim? Follow the repository on GitHub and vote for it on vim.org. And if you're feeling especially charitable, follow tpope on Twitter and GitHub.

License

Copyright © Tim Pope. Distributed under the same terms as Vim itself. See :help license.

vim-jdaddy's People

Contributors

tpope avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-jdaddy's Issues

I see the install, but I don't get the commands (It's probably me)

I have installed vim-jdaddy and started it, but I don't have an aj or ij command.

I see it's getting loaded in the log file
Searching for "X:\vimfiles\plugin//*.vim"
Searching for "C:\apps\Vim/vimfiles\plugin/
/.vim"
sourcing "C:\apps\Vim\vimfiles\plugin\jdaddy.vim"
finished sourcing C:\apps\Vim\vimfiles\plugin\jdaddy.vim
Searching for "C:\apps\Vim\vim74\plugin/**/
.vim"

But when I type colon aj, it doesn't recognise the command.

What am I missing? I'm on windows 7 with gvim 7.4

Cannot pretty print json containing array

The plugin fails to pretty print the following json:

{"sections": [{"body": "It shall be lawful for the  Government, by notification in the official Gazette, to create new districts in any part of Bangladesh. Government may, from time to time, alter the limits of the existing districts in any part of Bangladesh.]"}]}

Note: A lone bracket at the end of the string.

jdaddy chokes on large JSON objects when cursor is at the top.

I was using this plugin with a really large JSON object (48k) and jdaddy would not work if I had my cursor anywhere near the beginning. I tried it on the opening bracket, and on the first key—both times it simply wouldn't run.

Through a fluke, I tried it on the end bracket and it worked. Not sure if this is a known limitation with large files. Also I was working on a sensitive work-related JSON object so I can't paste the actual object I was using. :( Sorry!

Steps to reproduce:

  1. Get large JSON object (>=48k?)
  2. Have it all ugly and not parsed. (It was also on one line.. Not sure if that mattered)
  3. Try to run gqaj on first bracket, or near beginning of line.
  4. Try to run gqaj on ending bracket

If I can help debug this in any way please let me know! I'm a novice Vim user, so I'm not familiar with Vimscript in anyway currently.

Thanks!

Prevent reordering of elements

Hi Tim,

I was playing around with this plugin, which is awesome like all your others that I have installed!

I was wondering if there is any way to stop the plugin from reordering all the elements.

I monkeying around and hoping just removing the sort() call would do the trick, but some things are still reordered.

I also tried just running !python -m json.tool on a selection, but it similarly reorders the elements.

I'm trying to replicate the functionality of JSONLint. It reformats all the punctuation and spacing without affecting the ordering. What I do love about your plugin vs JSONLint is that single element hashes are all put in one line.

Thanks again for the great plugin!

Add ex commands for convenience

Add EX commands for convenience because it can be hard to remember the key bindings for the macros. With commands, it is possible to search with a tool like FZF.vim or order complete the command if it starts with something intuitive like JSON.

Feature: strip quotes from keys (when possible)

I found this plugin pretty useful for moving some json into a regular .js file and only formatting the valid json parts of my file.
It would be nice if it was able to strip out quotes from keys by default, or as an option, so I can have more uniform styles.

Example input json:

{"key1":"val1",key2:"val2"}

Current output:

{
  "key1": "val1",
  key2: "val2"
}

Desired output:

{
  key1: "val1",
  key2: "val2"
}

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.