sponsor Vim development Vim logo Vim Book Ad

EntryComplete : Insert mode completion based on lines in designated files or buffers.

 script karma  Rating 0/0, Downloaded by 1616  Comments, bugs, improvements  Vim wiki

created by
Ingo Karkat
 
script type
utility
 
description
DESCRIPTION
Cheat sheets that contain a single phrase, formula, or function invocation per
line can be very helpful and are used by many people. Using such as a
completion source is difficult, though. The full line completion
(i_CTRL-X_CTRL-L) considers other buffers, but cannot be restricted to a
single one. And to trigger the completion, the base has to be written on a new
line; you cannot recall a phrase from within an existing one. All of this can
be avoided by using a snippet plugin, but the syntax to define them usually is
more complex (so one cannot directly use one's cheat sheet), and the
additional features interfere with easy definition. Also, not every snippet
plugin offers the popup selection aspect of insert-mode completion, so you may
have to remember the snippet name to recall it.

This plugin provides a highly configurable completion of lines found in
designated files or buffers, triggered by a keyword in front of the cursor.
With its flexibility, you can use custom cheat sheets for a project, filetype,
or particular buffer or window as well as global ones.

SOURCE
Inspired by
    http://stackoverflow.com/questions/27539429/vim-snippet-phrase-dropdown-menu

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 entry completion via CTRL-X CTRL-E
You can then search forward and backward via CTRL-N / CTRL-P, as usual.

CTRL-X CTRL-E           Find matches for entries (i.e. entire lines) from the
                        designated sources configured by
                        g:EntryComplete_Sources.
 
install details
INSTALLATION
The code is hosted in a Git repo at
    https://github.com/inkarkat/vim-EntryComplete
You can use your favorite plugin manager, or "git clone" into a directory used
for Vim packages. Releases are on the "stable" branch, the latest unstable
development snapshot on "master".

This script is also 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 EntryComplete*.vmb.gz
    :so %
To uninstall, use the :RmVimball command.

DEPENDENCIES
- Requires Vim 7.0 or higher.
- Requires the ingo-library.vim plugin (vimscript #4433), version 1.019 or
  higher.
- Requires the CompleteHelper.vim plugin (vimscript #3914), version 1.50 or
  higher.

CONFIGURATION
For a permanent configuration, put the following commands into your vimrc:

This completion uses designated files or buffers as completion sources. You
can configure window-local, buffer-local, or global Lists of sources. A Number
is taken as a Vim buffer, a String specifies a filespec, a List directly
specifies matches (either as simple strings, or match objects as described
under complete-items), a Funcref is invoked without arguments and should
return a List of filespecs / Numbers / Lists:
    let g:EntryComplete_Sources = [bufnr('lines.txt'), expand('~/.vimrc'),
    \   ['foo', 'bar', {'word': 'baz', 'menu': 'my favorite'}]
    \]
Files and buffers can consist of a header line. This must be the first line,
and only contain the words from complete-items. The separators in between
are then used to parse the remaining lines into completion objects. For
example:
    word|abbr|menu
    myxomatosis|mixi|A usually fatal viral disease of rabbits.

The default configuration checks for entries in entries/{filetype}.txt and
entries/{filetype}/*.txt in each 'runtimepath' directory, usually in your
user's configuration in ~/.vim/entries/.
You can add additional directories to be checked via
g:EntryComplete_FiletypeEntriesPath or b:EntryComplete_FiletypeEntriesPath.

If you want to use a different mapping, map your keys to the
<Plug>(EntryComplete) mapping target _before_ sourcing the script
(e.g. in your vimrc):
    imap <C-x><C-e> <Plug>(EntryComplete)
 

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
EntryComplete-1.20.vmb.gz 1.20 2018-05-27 7.0 Ingo Karkat - CHG: Use *.txt file extension for default entry files. This allows to put backups in the same directory without having them picked up.
- ENH: By default, also look into .../entries/{filetype}/*.txt for entries. This allows to easily use multiple entry sources for a filetype.
- ENH: Support parsing of files and buffers into complete match objects via a header line.
- Expose EntryComplete#Filetype#GetEntriesFilespecs(); it can be useful for customizations.
EntryComplete-1.10.vmb.gz 1.10 2017-03-09 7.0 Ingo Karkat - ENH: Support Lists of matches / match objects.
EntryComplete-1.00.vmb.gz 1.00 2014-12-23 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