sponsor Vim development Vim logo Vim Book Ad

QueryCommandComplete : Create completions from any command

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

created by
Caio Romão
script type
Query Command Complete

Vim plugin to suggest completions with the results of an external
query command.

The original intention is to use it as a mutt query_command wrapper
to complete addresses in the mail headers, but it can be adapted
to any other kind of functionality by modifying the exposed setting

Last Change: 2013 Jun 16
Author: Caio Romão (http://caioromao.com)
License: This file is placed in the public domain
  Brian Henderson https://github.com/bhenderson
  Mark Stillwell  https://github.com/marklee77
  Rui Abreu Ferreira http://ruiabreu.org

  This plugin exports the completion function QueryCommandComplete,
  which can be set as the complete function (or omni function) for
  any filetype. If you have a working mutt setup with query_command
  configured, the plugin works out of the box.

      let g:qcc_query_command='abook'
      au BufRead /tmp/mutt* setlocal omnifunc=QueryCommandComplete

  Note: Overriding settings on a buffer-basis is supported. So
        b:qcc_query_command takes precedence over g:qcc_query_command

      External command that queries for contacts
      If empty, QueryCommandComplete tries to guess what command to
      run by executing `mutt -Q query_command`.

      Separator for each entry in the result from the query
      default: '\n'

      Separator for the fields of an entry from the result
      default: '\t'

      Pattern used to match against the current line to decide
      whether to call the query command
      default: '^\(To\|Cc\|Bcc\|From\|Reply-To\):'

      Whether to try matching g:qcc_pattern against the current
      and any previous line
      default: 0

      Pattern to match against the current line when deciding
      wether to keep looking for a line that matches g:qcc_pattern
      This provides finer control over the recursion, which
      is useful if calling the completion on really big files.
      default: '.*'

      Format string to be used when building the word field
      of the completion (i.e.: the final result, what gets fed into
      the current line when you select an option)
      default: '${1} <${0}>' (as in: FirstName <email@domain.com>)

      Format string to be used when building the abbreviation
      for the completion menu (i.e.: the first row in the completion
      default: '${1}'

      Format string for the optional second column of the completion
      default: '${2}'
install details
Just put querycommandcomplete.vim inside your plugins folder.

For pathogen/vundle users:
- https://github.com/caio/querycommandcomplete.vim

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
querycommandcomplete.vim 0.4 2013-06-18 7.0 Caio Romão * Template support for the completion menu
* Read settings from buffer variables
* Dropped requirement for having everything set up during source time
querycommandcomplete.vim 0.3 2012-12-29 7.0 Caio Romão New features contributed by marklee77 on github: support for a placeholder (%s) in g:qcc_pattern and multiline feature (on my default if using the plugin without any configuration)
querycommandcomplete.vim 0.2 2012-09-17 7.0 Caio Romão New functionality contributed by bhenderson on github. Now the plugin can be used without previous configuration when the user has mutt properly setup.
querycommandcomplete.vim 0.1 2012-07-15 7.0 Caio Romão Initial upload
ip used for rating:

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.
SourceForge.net Logo