||9 months ago|
|autoload||9 months ago|
|LICENSE||9 months ago|
|README.md||9 months ago|
A set of helper functions to deal with relative file paths in Vim.
What it does
It can convert a file path (probably an absolute file path) to a path relative to a given directory.
How it does that
This also means that if you don’t have
realpath available, or if it doesn’t support the
--relative-to argument, relatifile won’t work.
Note that there is proof-of-concept code that gets rid of the
realpath dependency available in #1, it’s just not implemented or tested yet.
I’m probably to busy right now and
realpath works for me, but I’m open to pull requests.
names (can be either a string or a list of strings) to be relative to
names is a string, the value returned is also a string.
names is a list, a list is returned.
This allows you to convert multiple names with a single
relatifile#relative(names, expand('%:h')), i.e. make the
names relative to the current file.
relatifile#relative(names, getcwd()), i.e. make the
names relative to the current working directory.
Convert the file path under the cursor to one that’s relative to the current file.
This will do a
relative_to_current conversion for
expand('<cfile>:p'), then select the file under the cursor by setting
\m\f*\%#\f* followed by
gn, then replace it with the result.
File names with non-printable characters, especially file names with newlines in them, will probably confuse relatifile.
relatifile is maintained by Tim Weber. Its official home is at https://codeberg.org/scy/relatifile.
Currently, I consider this thing feature-complete. I might add additional things to scratch an itch.
Feel free to open issues for bugs and feature requests.