SameFiletypeComplete : Insert mode completion from buffers with the same filetype.
| script karma
Downloaded by 354
Comments, bugs, improvements
script versions (upload new version)
When editing multiple projects (e.g. Python and Java) concurrently, or even
when different types of files (like C source code, its Makefile, and the
corresponding HTML documentation) are open in Vim, the general insert-mode
completion i_CTRL-N becomes less useful. It searches for keywords in open
windows, listed buffers, and other sources as defined by the 'complete'
setting; there's no way to restrict the sources to consider only buffers that
have the same filetype as the current buffer, so a lot of unrelated cruft
clutters the list of completion matches.
This plugin offers an alternative completion that works like the general one,
but lists completion candidates only from buffers that have the same
'filetype' as the current buffer. When you're editing a Python file, you'll
only get matches from other open Python files. Switch to the Makefile and all
those inapplicable Python keywords won't be offered there.
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 =
You can then search forward and backward via CTRL-N / CTRL-P, as usual.
CTRL-X = Find matches for words that start with the
keyword in front of the cursor, looking only into
buffers with the same 'filetype'.
Further use of CTRL-X = will copy the words following
the previous expansion.
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.30 or
For a permanent configuration, put the following commands into your vimrc:
Analoguous to the 'complete' option, you can specify which buffers will be
scanned for completion candidates. Currently, '.' (current buffer), 'w'
(buffers from other windows), and 'b' (other listed buffers) are supported.
let g:SameFiletypeComplete_complete = '.,w,b'
The global setting can be overridden for a particular buffer
If you want to use a different mapping, map your keys to the
<Plug>(SameFiletypeComplete) mapping target _before_ sourcing the script (e.g.
in your vimrc):
imap <C-x>= <Plug>(SameFiletypeComplete)
Click on the package to download.
ip used for rating: 22.214.171.124