Skip to main content

Edit directory with vim

Project description

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vdir-0.5.1.tar.gz (93.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vdir-0.5.1-py3-none-any.whl (117.0 kB view details)

Uploaded Python 3

File details

Details for the file vdir-0.5.1.tar.gz.

File metadata

  • Download URL: vdir-0.5.1.tar.gz
  • Upload date:
  • Size: 93.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.14.3 HTTPX/0.28.1

File hashes

Hashes for vdir-0.5.1.tar.gz
Algorithm Hash digest
SHA256 865033ca764f768654557bf5b3d5ce82ac60942d705e98a9b5d552232ec9c1e6
MD5 9bc4033b1c0235fae8c502e73caaee84
BLAKE2b-256 17ef4c0e7bfeddad7ce3ebfa3fcf4bb4fe3518711e3ba385bcc1f3a9e30c1bbe

See more details on using hashes here.

File details

Details for the file vdir-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: vdir-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 117.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.14.3 HTTPX/0.28.1

File hashes

Hashes for vdir-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 88e7b162f788435de612e418d0f46da12def955232d0d0edeb6a9ee513414b70
MD5 450e44d4e7816ebe508723a0eb2856da
BLAKE2b-256 5b7092f810503129558293c6ced82cda7b38c357b8f927c3aa0a9cc534a3a92a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page