sponsor Vim development Vim logo Vim Book Ad

BufNameComplete : Insert mode completion of filenames loaded in Vim.

 script karma  Rating 2/2, Downloaded by 1285  Comments, bugs, improvements  Vim wiki

created by
Ingo Karkat
 
script type
utility
 
description
DESCRIPTION
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
    #include "lib/f|

SOURCE
This completion type was motivated by this Stack Overflow question:
    http://stackoverflow.com/questions/13406751/vim-completion-based-on-buffer-name

SEE ALSO
- Check out the CompleteHelper.vim plugin page (vimscript #3914) for a full
  list of insert mode completions powered by it.

USAGE
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.
 
install details
INSTALLATION
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.
    vim BufNameComplete*.vmb.gz
    :so %
To uninstall, use the :RmVimball command.

DEPENDENCIES
- Requires Vim 7.0 or higher.
- Requires the CompleteHelper.vim plugin (vimscript #3914), version 1.10 or
  higher.

CONFIGURATION
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
your vimrc):
    imap <C-x>f <Plug>(BufNameComplete)
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
BufNameComplete-1.00.vmb.gz 1.00 2012-11-16 7.0 Ingo Karkat Initial upload
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github