BracketComplete : Insert mode completion for text inside various brackets.
script karma |
Rating 0/0,
Downloaded by 2072 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
Ingo Karkat |
|
script type |
utility |
|
description |
DESCRIPTION
Frequently, text inside parentheses, be it a warning "(don't do this)" or
function arguments "(foo, bar, 42)" is repeated. This also applies to other
bracket delimiters, e.g. HTML tags "<img src='banner.jpg' alt=''>" or arrays
"[1, 2, 3]".
This plugin provides a completion mapping that, when you realize you're typing
the same contents of a bracket-delimited text again, completes the entire text
inside the brackets from other matches in the buffer. The completion base
always contains the entire text between the cursor and the previous opening
bracket, so it doesn't matter how far you've already been into retyping this.
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 %.
You can then search forward and backward via CTRL-N / CTRL-P, as usual.
CTRL-X % Find matches for the text before the cursor, up to the
previous bracket ( [ { < on the current line, and
offer matches of the entire text inside the brackets,
like the i( i[ i{ i< text objects.
This also works for tag-blocks with the it text
object; "<b>f|" will complete to "<b>foo bar</b>". |
|
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 BracketComplete*.vmb.gz
:so %
To uninstall, use the :RmVimball command.
DEPENDENCIES
- Requires Vim 7.0 or higher.
- Requires the MotionComplete.vim plugin (vimscript #4265).
CONFIGURATION
The general MotionComplete-configuration applies here, too.
For a permanent configuration, put the following commands into your vimrc:
The recognized bracket types are defined via a Dictionary. Its keys are the
opening brackets, which are mapped to an object that must have an "opposite"
attribute that specifies the closing bracket. If there's a text object, it can
be specified via the "textobject" attribute (without the preceding "a" / "i");
otherwise, a search to the closing bracket is used to retrieve the text.
To add an imaginary bracketing from : to ;, use:
runtime plugin/BracketComplete.vim " Define the default brackets first.
let g:BracketComplete_BracketConfig[':'] = {'opposite': ';'}
If you want to use different mapping, map your keys to the
<Plug>(BracketComplete...) mapping target _before_ sourcing the script
(e.g. in your vimrc):
imap <C-x>% <Plug>(BracketComplete) |
|
script versions (upload new version)
Click on the package to download.
ip used for rating: 142.132.191.50
|