Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 198 lines (159 sloc) 8.561 kb
3d58935 Version 2.00
Ingo Karkat authored
1 *SnippetComplete.txt* Insert mode completion that completes defined abbreviations and other snippets.
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
2
3 SNIPPET COMPLETE by Ingo Karkat
4 *SnippetComplete.vim*
5 description |SnippetComplete-description|
3d58935 Version 2.00
Ingo Karkat authored
6 usage |SnippetComplete-usage|
7 installation |SnippetComplete-installation|
8 configuration |SnippetComplete-configuration|
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
9 integration |SnippetComplete-integration|
10 limitations |SnippetComplete-limitations|
11 known problems |SnippetComplete-known-problems|
12 todo |SnippetComplete-todo|
13 history |SnippetComplete-history|
14
15 ==============================================================================
16 DESCRIPTION *SnippetComplete-description*
17
18 Insert mode abbreviations and snippets can dramatically speed up editing, but
19 how does one remember all those shortcuts that are rarely used? You can list
20 all insert mode abbreviations via |:ia| to break out of this vicious circle,
3d58935 Version 2.00
Ingo Karkat authored
21 but switching to command mode for that is cumbersome.
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
22
23 This plugin offers a context-sensitive insert mode completion to quickly list
3d58935 Version 2.00
Ingo Karkat authored
24 and complete defined abbreviations directly while typing.
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
25
4ad7a57 Version 2.11: FIX: Must use numerical sort() for s:lastCompletionsByBase...
Ingo Karkat authored
26 SEE ALSO *
27
28 - The |SnippetCompleteSnipMate.vim| plugin (vimscript #4276) extends the
29 completion with snippets for the popular snipMate plugin (vimscript #2540).
30
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
31 ==============================================================================
32 USAGE *SnippetComplete-usage*
29f6015 Version 2.10
Ingo Karkat authored
33
34 In insert mode, optionally type part of the snippet shortcut or a fragment
35 from its expected expansion, and invoke the snippet completion via CTRL-X ].
36 You can then search forward and backward via CTRL-N / CTRL-P, as usual.
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
37 *i_CTRL-X_]*
29f6015 Version 2.10
Ingo Karkat authored
38 CTRL-X ] Find matches for abbreviations that start with the
3d58935 Version 2.00
Ingo Karkat authored
39 text in front of the cursor. If other snippet types
40 are registered, show those, too.
29f6015 Version 2.10
Ingo Karkat authored
41 If no matches were found that way, matches anywhere in
42 the snippet or in the snippet's expanded text will be
43 shown. So if you can't remember the shortcut, but a
44 word fragment from the resulting expansion, just try
45 with that.
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
46
47 There are three types of |abbreviations| (full-id,
48 end-id and non-id), which can consist of different
49 characters. Thus, there can be more than one candidate
50 for the existing completion base, e.g. "pre@c" can
51 expand into a full-id abbreviation starting with "c"
52 or into a non-id one starting with "pre@c". The
53 completion indicates such a ambiguity through the
54 message "base n of m; next: blah", and you can cycle
55 through the different completion bases by repeating
3d58935 Version 2.00
Ingo Karkat authored
56 the i_CTRL-X_] shortcut.
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
57
58 Matches are selected and inserted as with any other
59 |ins-completion|, see |popupmenu-keys|. If you use
60 <Space> or |i_CTRL-]| to select an abbreviation, it'll
3d58935 Version 2.00
Ingo Karkat authored
61 be expanded automatically.
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
62
f92e29a Version 2.20
Ingo Karkat authored
63 *i_CTRL-X_g]*
64 CTRL-X g] Find matches for buffer-local abbreviations that start
65 with the text in front of the cursor. If other snippet
66 types are registered, show those (local ones), too.
67
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
68 ==============================================================================
69 INSTALLATION *SnippetComplete-installation*
70
7d39682 Version 1.01: Using separate autoload script to help speed up Vim startu...
Ingo Karkat authored
71 This script is packaged as a |vimball|. If you have the "gunzip" decompressor
29f6015 Version 2.10
Ingo Karkat authored
72 in your PATH, simply edit the *.vmb.gz package in Vim; otherwise, decompress
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
73 the archive first, e.g. using WinZip. Inside Vim, install by sourcing the
7d39682 Version 1.01: Using separate autoload script to help speed up Vim startu...
Ingo Karkat authored
74 vimball or via the |:UseVimball| command. >
29f6015 Version 2.10
Ingo Karkat authored
75 vim SnippetComplete*.vmb.gz
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
76 :so %
3d58935 Version 2.00
Ingo Karkat authored
77 To uninstall, use the |:RmVimball| command.
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
78
79 DEPENDENCIES *SnippetComplete-dependencies*
80
3d58935 Version 2.00
Ingo Karkat authored
81 - Requires Vim 7.0 or higher.
29f6015 Version 2.10
Ingo Karkat authored
82 - Requires the |CompleteHelper.vim| plugin (vimscript #3914), version 1.10 or
83 higher.
f92e29a Version 2.20
Ingo Karkat authored
84 - Requires the |ingo-library.vim| plugin (vimscript #4433), version 1.009 or
85 higher.
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
86
87 ==============================================================================
88 CONFIGURATION *SnippetComplete-configuration*
89
29f6015 Version 2.10
Ingo Karkat authored
90 For a permanent configuration, put the following commands into your |vimrc|:
91
92 *SnippetComplete-remap*
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
93 If you want to use a different mapping, map your keys to the
f92e29a Version 2.20
Ingo Karkat authored
94 <Plug>(SnippetComplete...) mapping targets _before_ sourcing the script (e.g.
95 in your |vimrc|).
96 For example, to use CTRL-X <Tab> as the completion trigger, define this: >
3d58935 Version 2.00
Ingo Karkat authored
97 imap <C-x><Tab> <Plug>(SnippetComplete)
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
98 <
99 ==============================================================================
100 INTEGRATION *SnippetComplete-integration*
101
3d58935 Version 2.00
Ingo Karkat authored
102 There exist multiple snippet systems that extend the built-in abbreviations
103 with support for filetype-specific and more complex expansions, like allowing
104 placeholders and expansion of in-line scriptlets. One popular one is the
105 snipMate plugin (vimscript #2540).
106 Since there is a seamless transition from simple abbreviation to complex
107 snippet, it may help to have a completion for both sources. To support this,
108 this plugin allows to write completions for other snippet plugins with just a
109 little bit of configuration and a function to retrieve the valid snippets.
110 This completion can be stand-alone via a different mapping, or it can add the
111 snippets to the |i_CTRL-X_]| completion mapping provided here.
112
113 The definition of a snippet type consists of an object with the following
114 properties: >
115 let typeDefinition = {
116 \ '{typeName}': {
117 \ 'priority': 100,
118 \ 'pattern': '\k\+',
119 \ 'generator': function('MySnippets#Get')
120 \ }
121 \}
122 <
123 The {pattern} key specifies the valid syntax of the snippets; the {generator}
124 should return all snippets in the format of |complete-items|; the filtering
125 according to the completion base is done by this plugin itself.
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
126
3d58935 Version 2.00
Ingo Karkat authored
127 *g:SnippetComplete_RegisteredTypes*
128 To include the snippets in the |i_CTRL-X_]| completion mapping provided here: >
129 call extend(g:SnippetComplete_RegisteredTypes, typeDefinition)
130 <
131 To create a separate completion mapping for your type: >
132 inoremap <silent> <C-x>% <C-r>=SnippetComplete#PreSnippetCompleteExpr()<CR><C-r>=SnippetComplete#SnippetComplete(typeDefinition)<CR>
f92e29a Version 2.20
Ingo Karkat authored
133 < *g:SnippetComplete_LocalRegisteredTypes*
134 Like |g:SnippetComplete_RegisteredTypes|, but to include (preferably only
135 local) snippets in the |i_CTRL-X_g]| completion mapping for buffer-local
136 abbreviation https://github.com/tek/vim-argh/blob/master/autoload/argh.vim#L54 s.
137
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
138 ==============================================================================
139 LIMITATIONS *SnippetComplete-limitations*
140
141 KNOWN PROBLEMS *SnippetComplete-known-problems*
142
3d58935 Version 2.00
Ingo Karkat authored
143 - When <CR> is :map-expr to <C-Y> when pumvisible() to accept the current
144 entry, and there's additional processing after <C-Y> (in my case, <C-\><C-o>
145 to call a function) the completed abbreviation is not expanded any more.
146
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
147 TODO *SnippetComplete-todo*
148
3d58935 Version 2.00
Ingo Karkat authored
149 - Getting and sorting of matches when 'ignorecase' is on.
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
150
151 IDEAS *SnippetComplete-ideas*
152
153 ==============================================================================
154 HISTORY *SnippetComplete-history*
155
f92e29a Version 2.20
Ingo Karkat authored
156 2.20 03-Apr-2014
157 - ENH: Add CTRL-X g] mapping variant that limits the results to buffer-local
158 abbreviations. This is useful to quickly get an overview of
159 filetype-specific abbreviations, which are usually drowned in the sea of
160 global ones (and snippets if integrated).
161 - Add dependency to ingo-library (vimscript #4433). *** You need to separately
162 install ingo-library (vimscript #4433) version 1.009 (or higher)! ***
163
4ad7a57 Version 2.11: FIX: Must use numerical sort() for s:lastCompletionsByBase...
Ingo Karkat authored
164 2.11 15-Jan-2013
165 FIX: Must use numerical sort() for s:lastCompletionsByBaseCol.
166
29f6015 Version 2.10
Ingo Karkat authored
167 2.10 19-Oct-2012
168 - ENH: When no base doesn't match with the beginning of a snippet, fall back
169 to matches either anywhere in the snippet or in the snippet expansion.
170 - Truncate very long or multi-line snippet expansions in the popup menu. This
171 requires the CompleteHelper plugin. When the entire snippet doesn't fit into
172 the popup menu, offer it for showing in the preview window.
173 *** THIS PLUGIN NOW REQUIRES THE CompleteHelper PLUGIN (vimscript #3914) ***
174
061b1bf Version 2.01: - FIX: Vim 7.0/1 need preloading of functions referenced i...
Ingo Karkat authored
175 2.01 13-Aug-2012
176 - FIX: Vim 7.0/1 need preloading of functions referenced in Funcrefs.
177
3d58935 Version 2.00
Ingo Karkat authored
178 2.00 08-May-2012
179 - Modularize and generalize for completing other types of snippets (e.g. from
180 snipMate).
181
7d39682 Version 1.01: Using separate autoload script to help speed up Vim startu...
Ingo Karkat authored
182 1.01 25-Sep-2010
3d58935 Version 2.00
Ingo Karkat authored
183 Using separate autoload script to help speed up Vim startup.
7d39682 Version 1.01: Using separate autoload script to help speed up Vim startu...
Ingo Karkat authored
184
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
185 1.00 12-Jan-2010
3d58935 Version 2.00
Ingo Karkat authored
186 First published version.
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
187
188 0.01 08-Jan-2010
3d58935 Version 2.00
Ingo Karkat authored
189 Started development.
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
190
191 ==============================================================================
f92e29a Version 2.20
Ingo Karkat authored
192 Copyright: (C) 2010-2014 Ingo Karkat
193 The VIM LICENSE applies to this plugin; see |copyright|.
5f93947 Version 1.00: Initial upload
Ingo Karkat authored
194
195 Maintainer: Ingo Karkat <ingo@karkat.de>
196 ==============================================================================
197 vim:tw=78:ts=8:ft=help:norl:
Something went wrong with that request. Please try again.