BufNameComplete : Insert mode completion of filenames loaded in Vim.
| script karma
Downloaded by 344
Comments, bugs, improvements
script versions (upload new version)
The built-in filename completion i_CTRL-X_CTRL-F searches the file system
based on the current directory, so potentially there can be many matches.
But often, the file one wants to refer to is already open inside Vim.
This plugin offers an alternative filename completion that just considers
buffers loaded in Vim. Matches can start at any path component, so the mapping
is especially useful for inserting relative paths, e.g. in
This completion type was motivated by this Stack Overflow question:
- Check out the CompleteHelper.vim plugin page (vimscript #3914) for a full
list of insert mode completions powered by it.
In insert mode, invoke the completion via CTRL-X f
You can then search forward and backward via CTRL-N / CTRL-P, as usual.
CTRL-X f Search for filenames loaded in Vim buffers (:ls)
that start with the same 'isfname' characters as
before the cursor.
Any path component or the file name itself can start
with the characters. When there are no filename
characters before the cursor, both filename and
filespec (relative to the current directory) of all
loaded buffers are listed.
This script is packaged as a vimball. If you have the "gunzip" decompressor
in your PATH, simply edit the *.vmb.gz package in Vim; otherwise, decompress
the archive first, e.g. using WinZip. Inside Vim, install by sourcing the
vimball or via the :UseVimball command.
To uninstall, use the :RmVimball command.
- Requires Vim 7.0 or higher.
- Requires the CompleteHelper.vim plugin (vimscript #3914), version 1.10 or
For a permanent configuration, put the following commands into your vimrc:
If you want to use a different mapping, map your keys to the
<Plug>(BufNameComplete) mapping target _before_ sourcing the script (e.g. in
imap <C-x>f <Plug>(BufNameComplete)
Click on the package to download.
ip used for rating: 220.127.116.11