molsonkiko / JsonToolsNppPlugin

A Notepad++ plugin providing tools for JSON like linting, querying, a tree view, and CSV conversion.
Apache License 2.0
70 stars 9 forks source link

[Feature Request] Use tabs instead of spaces when pretty printing #38

Closed Kiryonn closed 1 year ago

Kiryonn commented 1 year ago

As in the title, adding the possibility to choose between spaces and tabs.

molsonkiko commented 1 year ago

I may consider doing this in the future. It's not a high priority because (a) adding a new special case to my pretty-printing functions would increase code bloat and impair performance, (b) all the usual reasons that people object to using tabs for indentation, and (c) if you care about saving space when printing JSON, you should just compress it.

Suppose you want to indent with tabs, and you have n spaces for indentation. Use the find/replace form (regular expression ON). Find/replace (?:^|(?!\A)\G)\t*\K\x20{n} with \t to convert all leading sequences of n spaces to tabs.

See this guide for more info on regular expressions.

Kiryonn commented 1 year ago

I already replace 4 spaces with tab using Ctr+h, which isn't that hard nor a pain to deal with tbh. It's just that i'm lazy and like tabs better since you can get better space management while having a readable code. I do agree that for using json in a code I'd rather just compress it. I just find spaces as annoying as tall grass in minecraft. Can be pretty, but it's a sore for the brain.

molsonkiko commented 1 year ago

Closed by latest commit.