No description
Find a file
2025-12-06 10:29:38 +01:00
.github chore: Move LICENSE to project root 2025-12-06 10:29:38 +01:00
src style: Improve code clarity 2025-05-14 10:48:46 +02:00
tests Add tests 2025-03-24 10:21:44 +01:00
LICENSE chore: Move LICENSE to project root 2025-12-06 10:29:38 +01:00
nimpsort.nimble ci: Leverage release-please 'extra-files' for nimble version 2025-04-28 13:12:17 +02:00

Nimpsort

This is a simple formatting tool that alphabetically sorts top-level import statements in Nim source files. It currently supports regular comma-separated imports, bracketed imports, and prefixed imports. It will also preserve (and properly align) postfix comments, if any.

Installation

Using Nimble

nimble install nimpsort

Compiling from source

nim c -d:release src/nimpsort.nim

Downloading binary

Pre-built binaries for Linux (AMD64) are available on the release page.

Example

Given the file myprog.nim:

import std/[os, logging, tables, strutils]
import ./[common, action, target, config] # aligned comment
import pkg/[regex, cligen]# misaligned comment
import sequtils, options  # another one

nimpsort myprog.nim will turn it into:

import std/[logging, os, strutils, tables]
import ./[action, common, config, target] # aligned comment
import pkg/[cligen, regex] # misaligned comment
import options, sequtils # another one

NOTE: nimpsort does not currently support, but will ignore, multi-line import statements:

import
  terminal,
  strutils,
  os