ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Indent​X

by socsieng ALL

A Sublime Text package for indenting and formatting XML and JSON content

Details

Installs

  • Total 47K
  • Win 25K
  • Mac 15K
  • Linux 7K
Jun 24 Jun 23 Jun 22 Jun 21 Jun 20 Jun 19 Jun 18 Jun 17 Jun 16 Jun 15 Jun 14 Jun 13 Jun 12 Jun 11 Jun 10 Jun 9 Jun 8 Jun 7 Jun 6 Jun 5 Jun 4 Jun 3 Jun 2 Jun 1 May 31 May 30 May 29 May 28 May 27 May 26 May 25 May 24 May 23 May 22 May 21 May 20 May 19 May 18 May 17 May 16 May 15 May 14 May 13 May 12 May 11 May 10
Windows 1 5 3 0 1 3 6 1 4 2 2 1 4 5 5 2 0 3 5 4 7 4 4 0 0 3 2 5 5 4 2 1 4 4 2 4 3 3 1 3 4 5 7 1 0 0
Mac 0 4 1 0 1 3 1 3 3 0 2 3 6 2 4 6 1 0 3 3 1 3 4 0 1 5 2 4 2 3 0 1 2 5 3 5 4 0 0 0 0 4 5 2 0 1
Linux 0 1 0 0 0 1 1 0 0 0 0 0 3 0 0 3 1 0 1 2 0 0 2 0 0 2 0 1 0 1 0 0 3 1 1 1 1 1 0 0 0 0 0 1 0 2
0510Jun 24Jun 21Jun 18Jun 15Jun 12Jun 9Jun 6Jun 3May 31May 28May 25May 22May 19May 16May 13May 10Jun 24 Linux: 0 Mac: 0 Windows: 1Jun 23 Linux: 1 Mac: 4 Windows: 5Jun 22 Linux: 0 Mac: 1 Windows: 3Jun 21 Linux: 0 Mac: 0 Windows: 0Jun 20 Linux: 0 Mac: 1 Windows: 1Jun 19 Linux: 1 Mac: 3 Windows: 3Jun 18 Linux: 1 Mac: 1 Windows: 6Jun 17 Linux: 0 Mac: 3 Windows: 1Jun 16 Linux: 0 Mac: 3 Windows: 4Jun 15 Linux: 0 Mac: 0 Windows: 2Jun 14 Linux: 0 Mac: 2 Windows: 2Jun 13 Linux: 0 Mac: 3 Windows: 1Jun 12 Linux: 3 Mac: 6 Windows: 4Jun 11 Linux: 0 Mac: 2 Windows: 5Jun 10 Linux: 0 Mac: 4 Windows: 5Jun 9 Linux: 3 Mac: 6 Windows: 2Jun 8 Linux: 1 Mac: 1 Windows: 0Jun 7 Linux: 0 Mac: 0 Windows: 3Jun 6 Linux: 1 Mac: 3 Windows: 5Jun 5 Linux: 2 Mac: 3 Windows: 4Jun 4 Linux: 0 Mac: 1 Windows: 7Jun 3 Linux: 0 Mac: 3 Windows: 4Jun 2 Linux: 2 Mac: 4 Windows: 4Jun 1 Linux: 0 Mac: 0 Windows: 0May 31 Linux: 0 Mac: 1 Windows: 0May 30 Linux: 2 Mac: 5 Windows: 3May 29 Linux: 0 Mac: 2 Windows: 2May 28 Linux: 1 Mac: 4 Windows: 5May 27 Linux: 0 Mac: 2 Windows: 5May 26 Linux: 1 Mac: 3 Windows: 4May 25 Linux: 0 Mac: 0 Windows: 2May 24 Linux: 0 Mac: 1 Windows: 1May 23 Linux: 3 Mac: 2 Windows: 4May 22 Linux: 1 Mac: 5 Windows: 4May 21 Linux: 1 Mac: 3 Windows: 2May 20 Linux: 1 Mac: 5 Windows: 4May 19 Linux: 1 Mac: 4 Windows: 3May 18 Linux: 1 Mac: 0 Windows: 3May 17 Linux: 0 Mac: 0 Windows: 1May 16 Linux: 0 Mac: 0 Windows: 3May 15 Linux: 0 Mac: 0 Windows: 4May 14 Linux: 0 Mac: 4 Windows: 5May 13 Linux: 0 Mac: 5 Windows: 7May 12 Linux: 1 Mac: 2 Windows: 1May 11 Linux: 0 Mac: 0 Windows: 0May 10 Linux: 2 Mac: 1 Windows: 0Jun 24 Linux: 0 Mac: 0 Windows: 1Jun 23 Linux: 1 Mac: 4 Windows: 5Jun 22 Linux: 0 Mac: 1 Windows: 3Jun 21 Linux: 0 Mac: 0 Windows: 0Jun 20 Linux: 0 Mac: 1 Windows: 1Jun 19 Linux: 1 Mac: 3 Windows: 3Jun 18 Linux: 1 Mac: 1 Windows: 6Jun 17 Linux: 0 Mac: 3 Windows: 1Jun 16 Linux: 0 Mac: 3 Windows: 4Jun 15 Linux: 0 Mac: 0 Windows: 2Jun 14 Linux: 0 Mac: 2 Windows: 2Jun 13 Linux: 0 Mac: 3 Windows: 1Jun 12 Linux: 3 Mac: 6 Windows: 4Jun 11 Linux: 0 Mac: 2 Windows: 5Jun 10 Linux: 0 Mac: 4 Windows: 5Jun 9 Linux: 3 Mac: 6 Windows: 2Jun 8 Linux: 1 Mac: 1 Windows: 0Jun 7 Linux: 0 Mac: 0 Windows: 3Jun 6 Linux: 1 Mac: 3 Windows: 5Jun 5 Linux: 2 Mac: 3 Windows: 4Jun 4 Linux: 0 Mac: 1 Windows: 7Jun 3 Linux: 0 Mac: 3 Windows: 4Jun 2 Linux: 2 Mac: 4 Windows: 4Jun 1 Linux: 0 Mac: 0 Windows: 0May 31 Linux: 0 Mac: 1 Windows: 0May 30 Linux: 2 Mac: 5 Windows: 3May 29 Linux: 0 Mac: 2 Windows: 2May 28 Linux: 1 Mac: 4 Windows: 5May 27 Linux: 0 Mac: 2 Windows: 5May 26 Linux: 1 Mac: 3 Windows: 4May 25 Linux: 0 Mac: 0 Windows: 2May 24 Linux: 0 Mac: 1 Windows: 1May 23 Linux: 3 Mac: 2 Windows: 4May 22 Linux: 1 Mac: 5 Windows: 4May 21 Linux: 1 Mac: 3 Windows: 2May 20 Linux: 1 Mac: 5 Windows: 4May 19 Linux: 1 Mac: 4 Windows: 3May 18 Linux: 1 Mac: 0 Windows: 3May 17 Linux: 0 Mac: 0 Windows: 1May 16 Linux: 0 Mac: 0 Windows: 3May 15 Linux: 0 Mac: 0 Windows: 4May 14 Linux: 0 Mac: 4 Windows: 5May 13 Linux: 0 Mac: 5 Windows: 7May 12 Linux: 1 Mac: 2 Windows: 1May 11 Linux: 0 Mac: 0 Windows: 0May 10 Linux: 2 Mac: 1 Windows: 0Jun 24 Linux: 0 Mac: 0 Windows: 1Jun 23 Linux: 1 Mac: 4 Windows: 5Jun 22 Linux: 0 Mac: 1 Windows: 3Jun 21 Linux: 0 Mac: 0 Windows: 0Jun 20 Linux: 0 Mac: 1 Windows: 1Jun 19 Linux: 1 Mac: 3 Windows: 3Jun 18 Linux: 1 Mac: 1 Windows: 6Jun 17 Linux: 0 Mac: 3 Windows: 1Jun 16 Linux: 0 Mac: 3 Windows: 4Jun 15 Linux: 0 Mac: 0 Windows: 2Jun 14 Linux: 0 Mac: 2 Windows: 2Jun 13 Linux: 0 Mac: 3 Windows: 1Jun 12 Linux: 3 Mac: 6 Windows: 4Jun 11 Linux: 0 Mac: 2 Windows: 5Jun 10 Linux: 0 Mac: 4 Windows: 5Jun 9 Linux: 3 Mac: 6 Windows: 2Jun 8 Linux: 1 Mac: 1 Windows: 0Jun 7 Linux: 0 Mac: 0 Windows: 3Jun 6 Linux: 1 Mac: 3 Windows: 5Jun 5 Linux: 2 Mac: 3 Windows: 4Jun 4 Linux: 0 Mac: 1 Windows: 7Jun 3 Linux: 0 Mac: 3 Windows: 4Jun 2 Linux: 2 Mac: 4 Windows: 4Jun 1 Linux: 0 Mac: 0 Windows: 0May 31 Linux: 0 Mac: 1 Windows: 0May 30 Linux: 2 Mac: 5 Windows: 3May 29 Linux: 0 Mac: 2 Windows: 2May 28 Linux: 1 Mac: 4 Windows: 5May 27 Linux: 0 Mac: 2 Windows: 5May 26 Linux: 1 Mac: 3 Windows: 4May 25 Linux: 0 Mac: 0 Windows: 2May 24 Linux: 0 Mac: 1 Windows: 1May 23 Linux: 3 Mac: 2 Windows: 4May 22 Linux: 1 Mac: 5 Windows: 4May 21 Linux: 1 Mac: 3 Windows: 2May 20 Linux: 1 Mac: 5 Windows: 4May 19 Linux: 1 Mac: 4 Windows: 3May 18 Linux: 1 Mac: 0 Windows: 3May 17 Linux: 0 Mac: 0 Windows: 1May 16 Linux: 0 Mac: 0 Windows: 3May 15 Linux: 0 Mac: 0 Windows: 4May 14 Linux: 0 Mac: 4 Windows: 5May 13 Linux: 0 Mac: 5 Windows: 7May 12 Linux: 1 Mac: 2 Windows: 1May 11 Linux: 0 Mac: 0 Windows: 0May 10 Linux: 2 Mac: 1 Windows: 0

Readme

Source
raw.​githubusercontent.​com

IndentX

IndentX is a forgiving indentation plugin for Sublime Text inspired by Indent Xml, aimed primarily at preserving attribute ordering and working with invalid content.

Supported content types:

  • XML-like content
  • JSON-like content

Available Commands

  • IndentX: Indent
  • IndentX: Indent & format JSON
  • IndentX: Convert JSON to YAML
  • IndentX: Unindent
  • IndentX: Report issue

Note: IndentX: Convert JSON to YAML should be considered alpha.

IndentX: Indent

The Indent command will format both XML and JSON like content (content guess based on the first character < for XML) and can be accessed using the following keyboard short-cuts (think angle brackets: control/command + k + <):

  • Windows: control + k + ,
  • Mac: command + k + ,
  • Linux: control + k + ,

XML before indenting:

Before XML indenting

XML after indenting:

After XML indenting

IndentX: Indent & format JSON

The Indent & format JSON will try and indent and convert JavaScript-like objects to JSON (e.g. wrapping attributes in " and converting ' strings to "). It can be accessed using the following keyboard short-cuts (think curly braces: control/command + k + {):

  • Windows: control + k + [
  • Mac: command + k + [
  • Linux: control + k + [

JSON before and after formatting:

Before JSON formatting After JSON formatting

Note: If starting with a JavaScript object and you want to maintain the JavaScipt object format, use the Indent command instead.

IndentX: Convert JSON to YAML

The Convert JSON to YAML command will try to convert a JSON document into YAML. As this feature is still very new, my personal experience with YAML is limited, this feature should be considered very alpha. Please submit any issues you may have.

JSON before and YAML after converting:

Before YAML conversion After YAML conversion

IndentX: Unindent

The Unindent command removes comments and whitespace to format content into one line.

IndentX: Report issue

Launches a browser window with the recommended issue structure.

How it works

IndentX uses regular expressions (probably more than it should) to identify tokens to:

  • insert new lines
  • increase indentation (begin tag/object)
  • decrease indentation (end tag/object)

This technique has the following benefits:

  • doesn't require valid strict XML or JSON (close enough should be good enough)
  • preserves attribute order

Installation

Install using Package Control.

Issues

Known issues

There is a known issue when upgrading from previous versions of IndentX where sub modules aren't reloaded. The work-around for this is to restart Sublime Text.

A solution to this issue should be available soon.

Reporting issues

Please report any issues with this plugin with the following sample structure in the body:

Issue with command: {command name}

Sample input:

```
// provide sample here

```

Expected result:

```
// provide expected result here

```

Alternatively, the IndentX: Report issue command will launch a browser with this content pre-filled.