importsort-d 0.3.2

sort imports of a .d-file

To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

Sort Imports for D

sortimport-d can sort your dozens of import's in a .d file (no matter where)



Building from HEAD

Get the repository with git and compile everything with dub

$ git clone
$ cd importsort-d
$ dub build

If everything went fine, there should be a binary at bin/importsort-d.

Copy this into a directory included in $PATH (/usr/bin for example) to make this command work globally.

$ sudo cp bin/importsort-d /usr/bin/

or add this into your .bashrc, .zshrc, etc.

export PATH=$PATH:"<path/to/importsort-d>/bin/" # on bash or zsh
fish_add_path "<path/to/importsort-d>/bin/"     # on fish-shell

Building with DUB

$ dub fetch importsort-d
$ dub run importsort-d -- --help

This won't install the command globally, you always have to run dub run importsort-d <args>


$ importsort-d [-h] [-v] [-r] [-m] [-i] [-o <out>] [-k] [-a] [-r] <input...>

input may be omitted or set to - to read from STDIN

| option | description | | --------------------- | ---------------------------------------------- | | -h, --help | prints a help message | | -v, --verbose | prints useful debug messages | | | | | -k, --keep | keeps the line as-is instead of formatting | | -a, --attribute | public and static imports first | | -b, --binding | sorts by binding rather then the original | | -m, --merge | merge imports which uses same file | | | | | -r, --recursive | recursively search in directories | | -i, --inline | changes the input | | -o, --output <path> | writes to path rather then writing to STDOUT |


Look at the documentation at, if you want to use this project in code.


How to add importsort-d to Visual Studio Code?

There's a plugin called Run on Save. You can install it and set importsort-d as an onSave-hook:

"emeraldwalk.runonsave": {
    "commands": [
            "cmd": "importsort-d -i ${file}",
            "match": "\\.d$"

How to add importsort-d to VIM/NeoVIM?

Just add this to your .vimrc or init.vim

:autocmd BufWritePost * silent !importsort-d -i <afile>

Are cats cool?



  • [x] recursive searching (v0.2.0)
  • [x] merge imports (v0.3.0)
  • [ ] watch-mode (struggling with save-timings - can clear files)
  • you can add importsort-d into your onSave-hooks
  • [ ] support multiple imports in one line (demilited by ;)
  • [ ] stripping unused imports (maybe)

you got some ideas? Issue them!



  • the very first version
  • not a lot is implemented


  • added --recursive (see above)
  • option --keep becomes disabling formatting
  • option --inline doen't copy the original but creates a *.new and renames it afterwards
  • option --original becomes --binding and sorts by original by default
  • refactoring code


  • added --merge (see above)


  • added documentation for contributers (or people who really want to see my code)


This whole project is licensed under the beautiful terms of the zlib-license.

Further information here.

made with love and a lot of cat memes

  • Friedel Schoen
0.3.2 2022-Oct-26
0.3.1 2022-Oct-23
0.3.0 2022-Oct-22
0.2.0 2022-Oct-18
0.1.0 2022-Oct-10
Show all 6 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 17 downloads total

Short URL: