Skip to main content

VDIR - Edit directory with vim

Heavily inspired by vidir from moreutils and edir.

With a few different design choices:

  • vdir always prompts before applying changes

  • vdir doesn't integrate with git (for not accidentally messing up your staging area)

  • vdir displays an (arguably) pretty-looking preview of the changes

  • vdir pads sequence number to same width for visual block operations

  • vdir references LS_COLORS for coloring

  • vdir supports stage/unstage items dynamically

  • vdir supports stage/unstage items dynamically from shell commands' output

    • Shell commands could be piped
  • vdir supports sorting staged items by several attributes, each of them could be reversed

  • vdir treats symbolic links as files instead of resolving them

  • vdir supports editing symbolic links

  • vdir supports compress/uncompress files by tar, zip, and 7z.

Examples (shell)

Check version

sh$ vdir --version
vdir 0.4.1

Manage current diretory:

sh$ vdir

Manage everything including hidden files in current diretory:

sh$ vdir -a

Manage certain files:

sh$ vdir *.txt

Manage found files:

sh$ fd --type f | vdir

Examples (vim)

A vdir's vim session looks like this:

# ═════════════════════════════════════════════════════════════════════════════
# - Add paths to stage them. Globs are recognized.
# - Add a '#' before id to untrack an item.
# - Add a '+' before id to expand non-hidden items under the directory.
# - Add a '*' before id to expand all items under the directory.
# - Add a '@' before id to resolve the soft link.
# - Stage items by shell command output: (globs are not supported here)
#   $ find . -type f | grep py
# - Sort with:
#   :sort [-][type|isdir|isfile|isfifo|islink|path|basename|name|dirname|size|atime|mtime|ctime|birthtime] ...
# - Setup default vd.vimrc with:
#   $ vdir --vimrc
# ═════════════════════════════════════════════════════════════════════════════

110 ││ LICENSE
120 ││ README.md
131 ││ __pycache__/
140 ││ pyproject.toml
151 ││ vdir/

Paths could be added directly for next round editing.

Shell commands could be used to add paths in batch. Shell commands could be piped, but note that commands are ran one-by-one, i.e. each command's stdout is collected, returncode is checked, and then all pipe to stdin of the next command.

If one command fails (i.e. returncode != 0), the pipeline stops, and stderr is appended in comment.

The inventory could be sorted with :sort command. Several attributes are available, each of them could be prefixed with - for reversing the order. For example, :sort dirname -type basename sorts the inventory with dirname ascending, type decending, and basename ascending.

When you're done, save and quit, and vdir prompts you the changes like this:

[info] Delete:[LICENSE]
[info] Rename:[README.mdd]
Continue? [(Y)es / (n)o / (e)dit / (r)edo] _
  • y to apply and continue with another vim session
  • Empty input to apply and quit
  • n to cancel the edit
  • ctrl+c to cancel the edit if you're scared of the change
  • e to continue editing
  • r to restart with initial contents

Installation

vdir

sh$ pipx install vdir

Release files for vdir 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vdir 0.6.0
File Size Uploaded
vdir-0.6.0.tar.gz 95.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vdir 0.6.0
File Interpreter ABI Platform
vdir-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 213.1 kB

Release files / vdir-0.6.0.tar.gz

Download URL vdir-0.6.0.tar.gz
Size 95.1 kB
Tags Source
SHA-256 checksum
How to use checksums
aa6118d694b5c565ec517572a67286e63880f684c4e285777582f5817381e169
BLAKE2b-256 checksum
How to use checksums
8beb3f8b01b388b394a5b84e2b05c96ceec32ca3d16291081afcc34731230bfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.5 cpython/3.14.5 HTTPX/0.28.1

Release files / vdir-0.6.0-py3-none-any.whl

Download URL vdir-0.6.0-py3-none-any.whl
Size 118.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2051e5cc09b3821dc817aa8a169a724eddf2ab8c49bf884fcbb1ab2a48adce85
BLAKE2b-256 checksum
How to use checksums
f36f812b8cb74765b6db200b5210d7da793afe2aaf75142430a51b8793513b69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.5 cpython/3.14.5 HTTPX/0.28.1

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page