vim-relatively-complete

Vim plugin to complete files relative to the current file, unless path explicitly specified.
git clone git://git.alex.balgavy.eu/vim-relatively-complete.git
Log | Files | Refs | README

commit 98adbb2f1860e0cc259629127832437ce1df1d21
parent 9415d95d819b5d07a175de000532069f50949682
Author: Alex Balgavy <a.balgavy@gmail.com>
Date:   Wed, 15 Apr 2020 13:06:49 +0200

README

Diffstat:
AREADME.md | 21+++++++++++++++++++++
1 file changed, 21 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -0,0 +1,21 @@ +# vim-relatively-complete: insert file completion, relative to the current file +## Why? +By default, Vim's filename insert completion (`i_CTRL-X_CTRL-F`) completes files relative to the current working directory. +I've found that I generally instead want to complete files relative to the file in the current buffer. +That's why this plugin exists. + +## What? +This plugin modifies Vim's insert filename completion feature to complete files relative to the file in the current buffer. +If the cursor is positioned at the end of a (partial) absolute path, files are completed based on that path. +That is, if the cursor is positioned after e.g. `/etc/` in the current buffer, the plugin will complete files/directories in `/etc/` (just like standard insert completion). + +The plugin exposes one insert mode mapping: + +* `<Plug>CompleteRelative`: start completing filenames relative to the file in the current buffer + +There are no default mappings (by design, so as not to force mappings on users), so you need to map this `<Plug>` yourself. +For example, by putting this line in your .vimrc: `imap <C-x><C-f> <Plug>CompleteRelative`. + +**Disclaimer:** this code is not extensively tested. +It works for me, running Vim 8.2 in the terminal on macOS, but it's not guaranteed to work for others. +It might not work in Neovim, as I don't use Neovim.