LineComplete : Insert mode completion of entire lines based on looser matching.
| script karma
Downloaded by 77
Comments, bugs, improvements
script versions (upload new version)
The built-in i_CTRL-X_CTRL-L line completion allows to quickly grab entire
lines, but you have to know and type the first characters as a completion
base. That's bad if the start is difficult to type (e.g. because of comment
prefixes) or the key differentiating word only comes late in the line. On the
other hand, any indent is ignored, so you cannot reduce the number of matches
even if you know that the indent of the desired line is the same as the
This plugin offers an alternative full-line completion that considers any
existing indent, and lifts the restriction that matches must _start_ with the
completion base. Instead, the WORDs of the base can appear anywhere in the
line, with fallbacks allowing other WORDs in between or even the WORDs
appearing anywhere inside the line.
- 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 line completion via CTRL-X l
You can then search forward and backward via CTRL-N / CTRL-P, as usual.
CTRL-X l Find matches for whole lines that have the same indent
as the current line (only if any exists!) and match
the text before the cursor (not necessarily at the
start), falling back to a match of all WORDs before
the cursor (possibly with other text in between each,
but still in the given order), first as
space-separated WORDs, finally accepting matches
In contrast, the built-in i_CTRL-X_CTRL-L always
ignores the indent. This completion is stricter if
indent is given (it must match exactly), but otherwise
much more loose, because the completion base need not
specify the start of the line.
If you don't want the indent restriction, use
i_CTRL-U before typing the completion base to clear
Further use of CTRL-X l will copy the line after the
one that has been completed.
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).
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:LineComplete_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>(LineComplete) mapping target _before_ sourcing the script
(e.g. in your vimrc):
imap <C-x>l <Plug>(LineComplete)
Click on the package to download.
ip used for rating: 188.8.131.52