Satisfy Your Inner OCD: Introducing `inifmt` for Pretty INI Files
hive-186392·@thecrazygm·
9.410 HBDSatisfy Your Inner OCD: Introducing `inifmt` for Pretty INI Files
Hey everyone, Today's post is about a little command-line tool I built for a very specific, and perhaps slightly obsessive, reason. I'm a bit OCD when it comes to formatting, and I've always found `.ini` style configuration files with misaligned equals signs to be visually jarring. They work fine, but they just don't _look_ nice. I looked at the inifmt that was available in the VSCode marketplace and underneath was an awk script, but didn't have many options. So, because this is what we developers do, I built a tool for my own convenience to fix it. I call it `inifmt`. #### What Does It Do? `inifmt` is a simple utility written in Go that reads an `.ini` file and reformats it to perfectly align the equals signs, along with other normalizations like trimming excess whitespace. For example, it can take a messy file like this `test.ini`: ```ini ; Test INI file for inifmt ; This file contains various INI formatting cases [section1] key1=value1 key2 = value2 key3 =value3 [section2] # Another comment style longer_key_name=should_align short=value [section3] ; Inline comment # Mixed comment styles spaces = should be normalized no_spaces=should_work_too ``` And with a simple command, turn it into this beautifully aligned `test2.ini`: ```ini ; Test INI file for inifmt ; This file contains various INI formatting cases [section1] key1 = value1 key2 = value2 key3 = value3 [section2] # Another comment style longer_key_name = should_align short = value [section3] ; Inline comment # Mixed comment styles spaces = should be normalized no_spaces = should_work_too ```  Ah, much better! It's a small thing, but it makes config files so much easier to scan visually. #### How It Works & Key Features The tool is designed to be simple and flexible. It can read from a file directly or from standard input, so you can pipe content to it. It also has a few flags to control its behavior: - **Global vs. Per-Section Alignment:** By default, it aligns everything based on the longest key in the entire file. If you prefer to align keys only within their own `[section]`, you can use the `--per-section` (or `-s`) flag. - **In-Place Writing:** If you want to modify the file directly, you can use the `--write` (or `-w`) flag. - **Simple Formatting:** If you don't want the alignment and just want to normalize the file to have single spaces around the equals sign, you can use the `--single-space` (or `-u`) flag. #### Where to Find It While I built this to scratch my own itch, I figured others might find it useful too. The code is open source and available on GitHub. The `README` has instructions for installation and usage. - **GitHub Repository:** [https://github.com/TheCrazyGM/inifmt](https://github.com/TheCrazyGM/inifmt) It’s a simple tool, but it's a great example of building something just because you want your digital workspace to be a little bit tidier. Let me know what you think! As always, Michael Garcia a.k.a. TheCrazyGM
👍 beco132, freecompliments, teamvn, hdmed, hetty-rowan, wongi, beststart, poplar-22, ngwinndave, hive-140084, pepetoken, fc-curation, fc-rewards, fc-arbitration, indiasierra, indeedly, trovepower, mmbbot, honeyjean24, jacor, moretea, morwhale, coolguy123, oadissin, braaiboy, guurry123, gurseerat, vrezyy, tub3r0, chrisly.social, vrezion, whitneyalexx, tengolotodo.leo, timix648, bankrobbery, d-a-d, pepe.voter, claudiavb, murtaza-7868, digi-alt, joeyarnoldvn, morwhaleplus, morwhalebonus, najat, wynella, svanbo, esmeesmith, fonestreet, mk992039, freemonster, partytime.inleo, lisamgentile1961, ijebest, calebmarvel24, steembasicincome, sbi2, sbi3, sbi4, anikys3reasure, piestrikesback, sbi-tokens, qwertm, briefmarken, hive-117638, sneakyninja, netzisde, bububoomt, thedailysneak, gamer00, pixelfan, chaosmagic23, chaos23, sports.power.bot, kiemis, toohip, youloseagain, tydynrain, mviews, holovision.stem, learn2code, calmphoenix, rudy-dj, kasih-sayang, stem.alfa, bbarelyseal, txracer, ichheilee, ecoinstant, eturnerx, fatman, votehero, msp-foundation, thefoundation, cryptoknight12, paulmoon410, jozefkrichards, pokerarema, dpend.active, sketching, mxm0unite, mmoonn, dr-animation, peakecoin, strangedad, peakecoin.matic, peakecoin.bnb, michupa, elderdark, beffeater, abreusplinter, heutorybr, omra-sky, likedeeler, niallon11, mes, adulruna, deggial, steemkeepers, dstampede, eforucom, jorgebgt, rosauradels, bntcamelo, longhunter, nvstly, georgeenting, herman-german, middle-earthling, ecoinstats, accelerator, ryosai, thecrazygm.bank, bengy, aakom, a-bot, bigmoneyman, archon-gov, irisworld, pof.archon, abrockman, monsterrerentals, everythingsmgirl, voxmortis, ykretz, cubapl, cryptoniusrex, fw206, woelfchen, lrekt01, gadrian, lolz.byte,