neosnippet.vim/doc/neosnippet.txt

1030 lines
28 KiB
Plaintext
Raw Normal View History

2012-09-27 12:17:07 +00:00
*neosnippet.txt*
2012-10-30 14:20:46 +00:00
The neo-snippet plugin contains the neocomplcache snippet source
2012-02-02 04:33:35 +00:00
2012-09-27 12:17:07 +00:00
Version: 3.0
2012-10-16 05:06:45 +00:00
Author: Shougo <Shougo.Matsu@gmail.com>
2012-02-02 04:33:35 +00:00
License: MIT license {{{
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
}}}
2012-09-27 12:17:07 +00:00
CONTENTS *neosnippet-contents*
2012-02-02 04:33:35 +00:00
2012-09-27 12:17:07 +00:00
Introduction |neosnippet-introduction|
Install |neosnippet-install|
Interface |neosnippet-interface|
Commands |neosnippet-commands|
Variables |neosnippet-variables|
Key mappings |neosnippet-key-mappings|
Functions |neosnippet-functions|
Examples |neosnippet-examples|
Snippet syntax |neosnippet-snippet-syntax|
2012-10-30 01:51:33 +00:00
FAQ |neosnippet-faq|
2012-09-27 12:17:07 +00:00
Changelog |neosnippet-changelog|
2012-02-02 04:33:35 +00:00
==============================================================================
2012-09-27 12:17:07 +00:00
INTRODUCTION *neosnippet-introduction*
2012-02-02 04:33:35 +00:00
This plugin analyzes snippet files which you can use for completion. It offers
2012-10-30 16:47:01 +00:00
functionality similar to snipMate.vim or snippetsEmu.vim. Since you can choose
snippets with the neocomplcache interface, you might have less trouble using
them, because you do not have to remember each snippet name.
2012-02-02 04:33:35 +00:00
==============================================================================
2012-09-27 12:17:07 +00:00
INSTALL *neosnippet-install*
2012-02-02 04:33:35 +00:00
2012-09-30 08:23:02 +00:00
1: Extract the file and put files in your Vim directory
2012-02-02 04:33:35 +00:00
(usually ~/.vim/ or Program Files/Vim/vimfiles on Windows).
2012-09-30 08:23:02 +00:00
Note: If you want to complete snippets, you must install neocomplcache
(https://github.com/Shougo/neocomplcache).
2012-02-02 04:33:35 +00:00
==============================================================================
2012-09-27 12:17:07 +00:00
INTERFACE *neosnippet-interface*
2012-02-02 04:33:35 +00:00
------------------------------------------------------------------------------
2012-09-27 12:17:07 +00:00
COMMANDS *neosnippet-commands*
2012-02-02 04:33:35 +00:00
2012-09-30 10:10:25 +00:00
:NeoSnippetMakeCache [filetype]
*:NeoSnippetMakeCache*
2012-10-30 08:25:43 +00:00
2012-11-03 03:33:18 +00:00
Creates a cache for the given [filetype] snippets. It
2012-12-08 13:57:59 +00:00
automatically chooses the current buffer's file type unless you
2012-11-03 03:33:18 +00:00
specify one by [filetype].
2012-02-02 04:33:35 +00:00
*:NeoComplCacheCachingSnippets*
2012-10-30 08:25:43 +00:00
Note: |:NeoComplCacheCachingSnippets| is an obsolete name.
:NeoSnippetEdit [{options}] [filetype]
*:NeoSnippetEdit*
2012-11-03 03:33:18 +00:00
Opens the [filetype] snippets to edit. It automatically
selects the current buffer's filetype unless you specify
another one by [filetype].
2012-10-04 03:35:07 +00:00
2012-11-03 03:33:18 +00:00
If the path to [filetype] snippets is a directory, it
automatically selects the "[filetype].snip" in the [filetype]
subdirectory.
It edits a snippet file in |g:neosnippet#snippets_directory|
2012-11-03 03:33:18 +00:00
with precedence. The snippets are re-cached automatically
2012-10-30 08:25:43 +00:00
when you save the file after edit.
*:NeoComplCacheEditSnippets*
2012-11-03 03:33:18 +00:00
The following parameters can be used as {options} to modify
the behavior of the command. Note: You must escape spaces with
a backslash "\".
2012-05-05 15:19:01 +00:00
2012-09-30 10:10:25 +00:00
*neosnippet-edit-options-vertical*
-vertical
2012-10-30 08:25:43 +00:00
Split the window vertically.
2012-05-05 15:19:01 +00:00
2012-09-30 10:10:25 +00:00
*neosnippet-edit-options-horizontal*
-horizontal
2012-10-30 08:25:43 +00:00
Split the window horizontally.
2012-09-30 10:10:25 +00:00
Note: The behavior is undefined when both options are set.
2012-02-02 04:33:35 +00:00
2012-09-30 10:10:25 +00:00
*neosnippet-edit-options-direction*
-direction={direction}
2012-11-03 03:33:18 +00:00
Define the split position rule. The default value is
"belowleft".
2012-09-30 10:10:25 +00:00
*neosnippet-edit-options-split*
-split
2012-10-30 08:25:43 +00:00
Split the buffer.
2012-09-30 10:10:25 +00:00
*neosnippet-edit-options-runtime*
-runtime
2012-11-03 03:33:18 +00:00
Edit the runtime (built-in standard) snippets instead of the
user snippets defined by 'g:neosnippet#snippets_directory'.
2012-09-30 10:10:25 +00:00
2012-10-30 08:25:43 +00:00
Note: |:NeoComplCacheEditSnippets| is an obsolete name.
2012-09-30 10:10:25 +00:00
:NeoComplCacheEdit -runtime [filetype]
2012-11-03 03:33:18 +00:00
Opens the [filetype] standard snippets to edit. It
automatically selects the current buffer's file type snippets
unless you specify a file type by [filetype]. The snippets are
re-cached automatically when you save the file after edit.
2012-09-30 10:10:25 +00:00
*:NeoComplCacheEditRuntimeSnippets*
2012-10-30 08:25:43 +00:00
Note: |:NeoComplCacheEditRuntimeSnippets| is an obsolete name.
2012-02-02 04:33:35 +00:00
2012-11-03 03:40:08 +00:00
:NeoSnippetSource [filename]
*:NeoSnippetSource*
Load [filetype] snippets.
Note: The loaded snippets are enabled in current buffer only.
2012-02-02 04:33:35 +00:00
------------------------------------------------------------------------------
2012-09-27 12:17:07 +00:00
VARIABLES *neosnippet-variables*
2012-02-02 04:33:35 +00:00
2012-09-30 09:04:48 +00:00
g:neosnippet#snippets_directory *g:neosnippet#snippets_directory*
2012-05-05 15:19:01 +00:00
This variable appoints a path to user-defined snippet files.
2012-11-03 03:33:18 +00:00
You can set multiple values in comma-separated form. Non
existing directories are ignored.
2012-05-05 15:19:01 +00:00
2012-11-03 03:33:18 +00:00
User defined snippet files are read after the built-in snippet
2012-12-08 13:57:59 +00:00
files. If redundant snippets occur they get overwritten and
2012-11-03 03:33:18 +00:00
only the last one remains.
2012-10-19 07:11:37 +00:00
2012-11-03 03:33:18 +00:00
Note: The neosnippet plug-in loads file type snippets from
several files if available. For example if you edit a "Vim"
file then it loads the snippets from:
2012-10-30 16:47:01 +00:00
- "vim.snip*"
- "vim_*.snip*"
- "vim/**/*.snip"
2012-05-05 09:08:56 +00:00
2012-09-30 09:04:48 +00:00
*g:neocomplcache_snippets_dir*
2012-10-30 08:25:43 +00:00
Note: |g:neocomplcache_snippets_dir| is an obsolete name.
2012-09-30 09:04:48 +00:00
2012-05-05 15:19:01 +00:00
This variable doesn't exist unless you declare it.
2012-02-02 04:33:35 +00:00
2012-09-30 09:04:48 +00:00
g:neosnippet#disable_select_mode_mappings
*g:neosnippet#disable_select_mode_mappings*
2012-11-03 03:33:18 +00:00
This variable disables key-mappings in |Select-mode| where the
snippets_complete performs the snippet completion. Usually it
2012-11-03 03:33:18 +00:00
it better to leave it as it is. But if you have troubles with
2012-10-30 16:47:01 +00:00
the buffer switcher LustyJuggler you can switch them of.
2012-09-30 09:04:48 +00:00
*g:neocomplcache_disable_select_mode_mappings*
Note: |g:neocomplcache_disable_select_mode_mappings| is an
2012-10-08 13:01:19 +00:00
obsolete name.
2012-09-30 09:04:48 +00:00
The default value is 1.
2012-02-02 04:33:35 +00:00
2012-09-30 09:04:48 +00:00
g:neosnippet#disable_runtime_snippets
*g:neosnippet#disable_runtime_snippets*
2012-10-30 16:47:01 +00:00
This is a dictionary variable which uses file types as key.
2012-11-03 03:33:18 +00:00
If you set the value of a file type entry to 1, this prevents
loading all the file type specific built-in snippets. This is
very useful to to prevent snippet conflicts between self
defined snippet files and the built-in snippet files of
2012-12-08 13:57:59 +00:00
neosnippet. If you use a "_" as key for an entry this will
2012-11-03 03:33:18 +00:00
treat the value of the entry as default value for all file
types.
Note: This dictionary must be set in your .vimrc.
2012-02-02 04:33:35 +00:00
For example:
>
let g:neosnippet#disable_runtime_snippets = {
\ 'c' : 1, 'cpp' : 1,
\ }
" Works like g:neocomplcache_snippets_disable_runtime_snippets
" which disables all runtime snippets
let g:neosnippet#disable_runtime_snippets = {
\ '_' : 1,
\ }
<
2012-09-30 09:04:48 +00:00
*g:neocomplcache_snippets_disable_runtime_snippets*
Note: |g:neocomplcache_snippets_disable_runtime_snippets| is
an obsolete name.
2012-09-30 09:04:48 +00:00
The default value is {}.
2012-02-02 04:33:35 +00:00
g:neosnippet#enable_snipmate_compatibility
*g:neosnippet#enable_snipmate_compatibility*
If it is non 0, neosnippet will enable snipMate compatibility
feature(For example: Filename() function).
The default value is 0.
2012-02-02 04:33:35 +00:00
------------------------------------------------------------------------------
2012-09-27 12:17:07 +00:00
KEY MAPPINGS *neosnippet-key-mappings*
2012-02-02 04:33:35 +00:00
2012-09-30 09:04:48 +00:00
<Plug>(neosnippet_expand_or_jump)
*<Plug>(neosnippet_expand_or_jump)*
2012-10-29 22:45:46 +00:00
s_<Plug>(neosnippet_expand_or_jump)
*s_<Plug>(neosnippet_expand_or_jump)*
2012-11-03 03:33:18 +00:00
Expand a snippet in the current cursor position. If there is
no snippet available it jumps to the next placeholder of the
buffer.
2012-05-05 09:08:56 +00:00
2012-09-30 09:04:48 +00:00
*<Plug>(neocomplcache_snippets_expand)*
Note: |<Plug>(neocomplcache_snippets_expand)| is an obsolete
2012-09-30 09:04:48 +00:00
name.
2012-02-02 04:33:35 +00:00
2012-09-30 09:04:48 +00:00
<Plug>(neosnippet_jump_or_expand)
*<Plug>(neosnippet_jump_or_expand)*
2012-10-29 22:45:46 +00:00
s_<Plug>(neosnippet_jump_or_expand)
*s_<Plug>(neosnippet_jump_or_expand)*
2012-11-03 03:33:18 +00:00
Jump to the next available placeholder in the buffer. If there
is no placeholder it expands a snippet in the current cursor
position.
2012-02-02 04:33:35 +00:00
2012-09-30 09:04:48 +00:00
*<Plug>(neocomplcache_snippets_jump)*
Note: |<Plug>(neocomplcache_snippets_jump)| is an obsolete
2012-09-30 09:04:48 +00:00
name.
<Plug>(neosnippet_expand)
2012-10-01 02:47:04 +00:00
*<Plug>(neosnippet_expand)*
2012-10-29 22:45:46 +00:00
s_<Plug>(neosnippet_expand)
*s_<Plug>(neosnippet_expand)*
2012-11-03 03:33:18 +00:00
Expand a snippet in current cursor position. It only takes
effect if there is a snippet text to expand or if you have
chosen one from the neocomplcache drop down menu.
2012-02-02 04:33:35 +00:00
2012-09-30 09:04:48 +00:00
*<Plug>(neocomplcache_snippets_force_expand)*
Note: |<Plug>(neocomplcache_snippets_force_expand)| is
an obsolete name.
2012-09-30 09:04:48 +00:00
<Plug>(neosnippet_jump)
*<Plug>(neosnippet_jump)*
2012-10-29 22:45:46 +00:00
s_<Plug>(neosnippet_jump)
*s_<Plug>(neosnippet_jump)*
2012-11-03 03:33:18 +00:00
Jump to the next placeholder key. It does not expand any
snippets.
2012-02-02 04:33:35 +00:00
2012-09-30 09:04:48 +00:00
*<Plug>(neocomplcache_snippets_force_jump)*
Note: |<Plug>(neocomplcache_snippets_force_jump)| is
an obsolete name.
2012-09-30 09:04:48 +00:00
2012-10-04 05:21:05 +00:00
i_<Plug>(neosnippet_start_unite_snippet)
*i_<Plug>(neosnippet_start_unite_snippet)*
2012-11-03 03:33:18 +00:00
Starts the unite snippet source. You can expand a snippet by
the unite interface.
Note: The plug-in |unite.vim| is required for that feature.
2012-09-30 09:04:48 +00:00
*<Plug>(neocomplcache_start_unite_snippet)*
2012-11-03 03:33:18 +00:00
Note: |<Plug>(neocomplcache_start_unite_snippet)| is an
obsolete name.
2012-02-02 09:17:45 +00:00
2012-10-29 22:45:46 +00:00
x_<Plug>(neosnippet_expand_target)
*x_<Plug>(neosnippet_expand_target)*
Expand the input trigger by a selected target text.
2012-10-29 22:45:46 +00:00
x_<Plug>(neosnippet_start_unite_snippet_target)
2012-11-03 03:33:18 +00:00
*x_<Plug>(neosnippet_start_unite_snippet_target)*
Expand the input trigger by a selected target text by the
unite interface.
Note: The plug-in |unite.vim| is required for that feature.
x_<Plug>(neosnippet_register_oneshot_snippet)
2012-11-03 03:33:18 +00:00
*x_<Plug>(neosnippet_register_oneshot_snippet)*
Register oneshot snippet in the current buffer.
2012-09-30 09:13:49 +00:00
neosnippet#expandable()
*neosnippet#expandable()*
2012-11-03 03:33:18 +00:00
You can use this function with imap <expr>. It checks whether
the cursor text is a snippet trigger. This is is useful to
save key mappings.
2013-01-07 01:39:44 +00:00
Note: If you used to
|neocomplcache#sources#snippets_complete#expandable()|, you
must use |neosnippet#expandable_or_jumpable()|.
2012-09-30 09:13:49 +00:00
*neocomplcache#sources#snippets_complete#expandable()*
2012-09-27 12:17:07 +00:00
*neocomplcache#sources#snippets_complete#force_expandable()*
2012-09-30 09:13:49 +00:00
Note:
|neocomplcache#sources#snippets_complete#expandable()|
and
|neocomplcache#sources#snippets_complete#force_expandable()|
2012-10-30 08:25:43 +00:00
are obsolete names.
2012-09-30 09:13:49 +00:00
neosnippet#jumpable()
*neosnippet#jumpable()*
You can use this function with imap <expr>. It checks if the
cursor text is an existing placeholder in current buffer. This
is useful to save key mappings.
2012-09-30 09:13:49 +00:00
*neocomplcache#sources#snippets_complete#jumpable()*
Note: |neocomplcache#sources#snippets_complete#jumpable()| is
2012-10-30 08:25:43 +00:00
an obsolete name.
2012-09-30 09:13:49 +00:00
neosnippet#expandable_or_jumpable()
*neosnippet#expandable_or_jumpable()*
You can use this function with imap <expr>. It checks whether
the cursor text is a snippet trigger or a placeholder. This is
is useful to save key mappings.
2013-01-26 21:56:06 +00:00
Note: You don't like to jump to next placeholder, you must use
|neosnippet#expandable()| instead of
|neosnippet#expandable_or_jumpable()|.
>
imap <expr><C-l>
\ neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<C-n>"
<
2012-06-06 01:05:36 +00:00
------------------------------------------------------------------------------
2012-09-27 12:17:07 +00:00
FUNCTIONS *neosnippet-functions*
2012-06-06 01:05:36 +00:00
2012-09-30 09:13:49 +00:00
neosnippet#get_snippets_directory()
*neosnippet#get_snippets_directory()*
2012-06-06 01:05:36 +00:00
Gets snippet directories. This directories contain runtime
2012-09-30 09:13:49 +00:00
snippets directories and |g:neosnippet#snippets_directory|
2012-06-06 01:05:36 +00:00
directories.
2012-09-30 09:13:49 +00:00
*neocomplcache#sources#snippets_complete#get_snippets_dir()*
Note:
|neocomplcache#sources#snippets_complete#get_snippets_dir()|
2012-10-30 08:25:43 +00:00
is an obsolete name.
2012-09-30 09:13:49 +00:00
2012-02-02 04:33:35 +00:00
==============================================================================
2012-09-27 12:17:07 +00:00
EXAMPLES *neosnippet-examples*
2012-02-02 04:33:35 +00:00
>
" Plugin key-mappings.
2012-09-30 09:13:49 +00:00
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
2012-10-29 22:45:46 +00:00
xmap <C-k> <Plug>(neosnippet_expand_target)
2012-10-31 05:51:53 +00:00
xmap <C-l> <Plug>(neosnippet_start_unite_snippet_target)
2012-05-05 09:08:56 +00:00
2012-02-02 04:33:35 +00:00
" SuperTab like snippets behavior.
"imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
2012-09-30 09:13:49 +00:00
" \ "\<Plug>(neosnippet_expand_or_jump)"
" \: pumvisible() ? "\<C-n>" : "\<TAB>"
"smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
2012-10-14 00:51:30 +00:00
" \ "\<Plug>(neosnippet_expand_or_jump)"
" \: "\<TAB>"
2012-05-05 09:08:56 +00:00
2012-02-02 04:33:35 +00:00
" For snippet_complete marker.
if has('conceal')
set conceallevel=2 concealcursor=i
endif
" Enable snipMate compatibility feature.
" let g:neosnippet#enable_snipmate_compatibility = 1
2012-02-02 04:33:35 +00:00
==============================================================================
2012-09-27 12:17:07 +00:00
SNIPPET SYNTAX *neosnippet-snippet-syntax*
2012-02-02 04:33:35 +00:00
2012-10-30 20:45:29 +00:00
It is quite easy to create your own snippets starting with the example below.
The snippet syntax is close to the one of |snipMate|.
2012-02-02 04:33:35 +00:00
Example:
2012-10-30 20:45:29 +00:00
2012-02-02 04:33:35 +00:00
>
2012-11-03 03:33:18 +00:00
snippet [name]
abbr [abbreviation]
alias [aliases]
2012-12-08 13:57:59 +00:00
regexp [pattern]
2012-11-03 03:33:18 +00:00
options [options]
if ${1:condition}
${2}
endif
2012-02-02 04:33:35 +00:00
<
2012-10-21 08:51:07 +00:00
2012-10-30 20:45:29 +00:00
Snippet Keywords:
2012-11-05 07:41:01 +00:00
- snippet [name] (Required)
2012-10-30 20:45:29 +00:00
Each snippet starts with the keyword "snippet". This keyword is directly
followed by the snippet name. The snippet name is used for the expansion of
the snippet.
2012-11-05 07:41:01 +00:00
- abbr [name] (Optional)
2012-10-30 16:47:01 +00:00
2012-11-03 03:33:18 +00:00
Here you can define an abbreviation of the snippet which will be used in
the drop down menu of neocomplcache.
2012-10-30 20:45:29 +00:00
2012-11-05 07:41:01 +00:00
- alias [aliases] (Optional)
2012-10-30 20:45:29 +00:00
If you specify an alias it will be also used to expand a snippet. You can
2012-10-31 07:35:20 +00:00
define multiple aliases either using the separators ' ' or ','.
2012-10-30 20:45:29 +00:00
Example
2012-10-30 16:47:01 +00:00
2012-02-02 04:33:35 +00:00
>
2012-10-30 20:45:29 +00:00
alias hoge hogera hogehoge
2012-02-02 04:33:35 +00:00
<
2012-05-05 15:19:01 +00:00
2012-11-05 07:41:01 +00:00
- regexp [pattern] (Optional)
2012-11-03 06:35:27 +00:00
2012-12-08 13:57:59 +00:00
This snippet expands when it matched by the regexp pattern only.
2012-11-03 06:35:27 +00:00
Example
>
regexp '^% '
<
2012-11-05 07:41:01 +00:00
- options [options] (Optional)
2012-10-30 20:45:29 +00:00
2012-12-08 13:57:59 +00:00
Options influence the snippet behavior. The possible options are:
2012-10-31 07:35:20 +00:00
2012-11-03 03:33:18 +00:00
+ word This snippet expands by a word boundary. Note: To complete
the trigger in snippets_complete, it must be word(digits or
2012-10-31 07:35:20 +00:00
alphabet characters or "_") characters.
>
2012-11-03 03:33:18 +00:00
snippet date
options word
`strftime("%d %b %Y")`
2012-10-31 07:35:20 +00:00
<
+ head This snippet expands on the beginning of a line only.
2012-11-03 03:33:18 +00:00
Note: This is the same as "prev_word '^'" which is still
2012-10-31 07:35:20 +00:00
there for backwards compatibility.
>
2012-11-03 03:33:18 +00:00
snippet if
options head
2012-11-03 03:33:18 +00:00
if ${1:condition}
${2}
endif
2012-10-31 07:35:20 +00:00
<
2012-11-03 03:33:18 +00:00
+ indent Neosnippet indents the snippet after expansion to the same
column as the line above.
2012-10-31 07:35:20 +00:00
Below the keywords starts the snippet which gets expanded. After the snippet
expansion you can jump to the placeholders and replace them with desired text.
2012-10-30 20:45:29 +00:00
The structure of a placeholder can be:
- ${number:placeholder text}
2012-11-03 03:33:18 +00:00
2012-10-30 20:45:29 +00:00
Here the number of the placeholder and the placeholder text that are
2012-12-08 13:57:59 +00:00
separated by a ":" are embraced by a pair of "{}". The text is displayed
2012-11-03 03:33:18 +00:00
after the snippet expansion and gets replaced by your text. If you jump
over the snippet and do not insert any text in that position the
placeholder text remains there. This can be used as a standard value for a
certain position.
2012-02-02 04:33:35 +00:00
2012-10-30 20:45:29 +00:00
Example
2012-10-30 16:47:01 +00:00
2012-02-02 04:33:35 +00:00
>
2012-11-03 03:33:18 +00:00
snippet if
if ${1:condition}
${2}
endif
2012-02-02 04:33:35 +00:00
<
2012-10-30 16:47:01 +00:00
2012-10-30 20:45:29 +00:00
- ${number:#:placeholder text}
2012-12-08 13:57:59 +00:00
Here the number is followed by the "#" character. If you jump over this
2012-11-03 03:33:18 +00:00
placeholder and do not insert any text, the placeholder text will be
removed.
2012-10-30 20:45:29 +00:00
Example
2012-10-30 16:47:01 +00:00
2012-10-17 08:43:23 +00:00
>
2012-11-03 03:33:18 +00:00
snippet if
if ${1:#:condition}
${2}
endif
2012-10-30 20:45:29 +00:00
<
- ${number:TARGET}
This is the target placeholder which will be replaced by the text which is
2012-11-03 03:33:18 +00:00
selected before snippet expansion.
Note: You need to expand you snippet with the key mapping below for this to
work.
2012-10-30 20:45:29 +00:00
|<Plug>(neosnippet_expand_target)|.
This is very useful if you edit text and decide to put something in an
environment or some sort of brackets.
Example
>
2012-11-03 03:33:18 +00:00
snippet if
if ${1:#:condition}
${2:TARGET}
endif
2012-10-30 20:45:29 +00:00
<
- ${number}
This is a placeholder which you can use as a simple jump position. This
can be useful if you edit a placeholder inside of some sort of brackets or
environment and after that want to go on behind that.
Example
>
2012-11-03 03:33:18 +00:00
snippet if
if ${1:#:condition}
${2:do}
endif
${3}
2012-10-17 08:43:23 +00:00
<
2012-10-30 20:45:29 +00:00
- $number
2012-12-07 21:18:34 +00:00
This is a synchronized placeholder. Sometimes it is required to repeat a
2012-11-03 03:33:18 +00:00
value in several places inside a snippet. If you set the number of this
placeholder to the same number as one of the other placeholders in the
snippet it will repeat its content. $1 is synchronized to ${1} and so on.
$0 will be the final jump placeholder.
2012-10-30 20:45:29 +00:00
Example
2012-10-30 16:47:01 +00:00
2012-02-02 04:33:35 +00:00
>
snippet namespace
namespace ${1:name} {
2013-02-16 11:23:13 +00:00
${0}
} // namespace $1
2012-02-02 04:33:35 +00:00
<
2012-10-30 16:47:01 +00:00
2012-11-03 03:33:18 +00:00
Note: If you like to include characters in snippets that already have a
special meaning to neosnippet you need to escape them with a backslash.
2012-10-30 16:47:01 +00:00
2012-10-19 09:38:52 +00:00
>
2012-11-03 03:33:18 +00:00
snippet code
\`${1}\`${2}
2012-10-30 20:45:29 +00:00
2012-11-03 03:33:18 +00:00
snippet test
${1:escape \} value}
2012-10-19 09:38:52 +00:00
<
2012-10-30 16:47:01 +00:00
2012-10-30 20:45:29 +00:00
A placeholder value can not contain new lines. The snippet below isn't valid.
2012-02-02 04:33:35 +00:00
>
2012-11-03 03:33:18 +00:00
snippet invalid
${1:constructor: (${2:args\}) ->
${3:# do smth}}
2012-02-02 04:33:35 +00:00
<
2012-05-05 15:19:01 +00:00
2012-10-30 20:45:29 +00:00
Vim has a built-in expression evaluation. You can also use this feature inside
of snippets if you use back ticks like in the example below where "%:t" gets
expanded to name of the current active file when the snippet gets expanded and
the current time gets inserted by the expansion of the strftime command.
2012-02-02 04:33:35 +00:00
>
2012-11-03 03:33:18 +00:00
snippet header
File: ${1:`expand('%:t')`}
${2:Created at: `strftime("%B %d, %Y")`}
2012-02-02 04:33:35 +00:00
<
2012-10-30 20:45:29 +00:00
You can also nest the placeholders if you escape the special characters.
2012-10-29 20:09:50 +00:00
>
2012-11-03 03:33:18 +00:00
snippet div
<div ${1:id="${2:someid\}"}>${3}</div>${4}
2012-10-29 20:09:50 +00:00
<
2012-10-30 20:45:29 +00:00
In some cases you need to escape the "}" twice as the example below shows.
2012-10-29 22:45:46 +00:00
>
2012-11-03 03:33:18 +00:00
snippet catch
options head
catch ${1:/${2:pattern: empty, E484, Vim(cmdname):{errmsg\\}\}/}
2012-10-29 22:45:46 +00:00
<
2012-10-30 20:45:29 +00:00
This is because ${1:} substitutes the pattern to "/${2:pattern: empty, E484,
Vim(cmdname):{errmsg\}}" and ${2:} substitutes the pattern to "pattern: empty,
E484, Vim(cmdname):{errmsg}"
If you create a snippet file and prepend the filename with a "_" neosnippet
treats the snippets inside the file as global. This means that they will be
2012-11-03 03:33:18 +00:00
available for all file types (e.g _.snip). You can include other snippet files
from within a snippet file with.
2012-10-30 20:45:29 +00:00
2012-10-19 02:02:08 +00:00
>
2012-10-30 20:45:29 +00:00
include c.snip
2012-10-19 02:02:08 +00:00
<
2012-02-02 04:33:35 +00:00
Or if you want to include a whole directory with file type snippets.
2012-10-20 03:55:19 +00:00
2012-02-02 04:33:35 +00:00
>
2012-10-30 20:45:29 +00:00
include javascript/*
2012-02-02 04:33:35 +00:00
<
2012-10-30 20:45:29 +00:00
If you include snippet files it can happen that the same snippet name is used
multiple times in different snippet files. Neosnippet produces a warning if it
detects this. If you want to overwrite a snippet explicitly, please use:
2012-02-02 04:33:35 +00:00
>
2012-10-30 20:45:29 +00:00
delete snippets_name
2012-02-02 04:33:35 +00:00
<
2012-10-30 20:45:29 +00:00
After that you can redefine the snippet. But this does not work if you include
external snippet files. There will be no warning when snippets get overwritten.
2012-10-20 03:59:02 +00:00
Multi snippet feature in snipMate is available.
Neosnippet substitutes trigger and descriptions spaces to '_'.
2012-02-02 04:33:35 +00:00
>
snippet trigger description1
2012-10-19 02:02:08 +00:00
hoge
2012-02-02 04:33:35 +00:00
snippet trigger description2
2012-10-19 02:02:08 +00:00
piyo
2012-02-02 04:33:35 +00:00
<
2012-10-19 02:02:08 +00:00
2012-10-20 03:59:02 +00:00
If you use hard-tab for indentation in snippet file, neosnippet will use
2012-07-02 02:37:14 +00:00
'shiftwidth' instead of Vim indent plugin. This feature is useful while some
languages' indent files can not work very well (e.g.: PHP, Python).
2012-02-02 04:33:35 +00:00
>
snippet if
2012-11-03 03:33:18 +00:00
if (${1:/* condition */}) {
${2:// code...}
}
2012-02-02 04:33:35 +00:00
<
2012-10-21 09:03:10 +00:00
2012-11-05 03:01:14 +00:00
Note: "#{string}" is comment string. But it must be in head.
>
# It is comment string
# It is not comment string!
<
2012-11-05 07:41:01 +00:00
2012-12-08 13:57:59 +00:00
Note: Neosnippet ignores empty or spaces lines in snippet end. If you want to insert empty
2012-11-05 07:59:39 +00:00
line in snippet end, you must insert placeholder.
2012-11-05 07:41:01 +00:00
>
# This is valid.
snippet #!
abbr #!/usr/bin/env ruby
alias shebang
options head
#!/usr/bin/env ruby
${0}
2012-11-05 07:59:39 +00:00
# This is invalid(ignores spaces lines!).
2012-11-05 07:41:01 +00:00
snippet #!
abbr #!/usr/bin/env ruby
alias shebang
options head
#!/usr/bin/env ruby
2012-11-05 07:59:39 +00:00
2012-11-05 07:41:01 +00:00
<
Note: If you expand oneline snippet, the markers will be deleted in
|InsertLeave|.
2012-11-05 07:41:01 +00:00
2012-02-02 04:33:35 +00:00
==============================================================================
2012-09-27 12:17:07 +00:00
UNITE SOURCES *neosnippet-unite-sources*
2012-02-02 04:33:35 +00:00
2012-09-27 12:17:07 +00:00
*neosnippet-unite-source-snippet*
2012-02-02 04:33:35 +00:00
snippet
2012-11-03 03:33:18 +00:00
The candidates of the snippet source are neosnippet snippets.
and their kind is "snippet". You can use the snippet source
with the mapping |<Plug>(neosnippet_start_unite_snippet)|.
2012-11-03 03:33:18 +00:00
But you can also execute it by ":Unite snippet". The snippet
source offers an edit action you can use to edit the snippet
files.
Example:
2012-02-02 04:33:35 +00:00
>
2012-09-30 09:13:49 +00:00
imap <C-s> <Plug>(neosnippet_start_unite_snippet)
2012-02-02 04:33:35 +00:00
<
2013-02-17 05:58:57 +00:00
*neosnippet-unite-source-neosnippet/user*
neosnippet/user
The candidates of the user snippet files.
*neosnippet-unite-source-neosnippet/runtime*
neosnippet/runtime
The candidates of the runtime snippet files.
2012-02-02 04:33:35 +00:00
source actions
2012-09-27 12:17:07 +00:00
snippet *neosnippet-unite-action-snippet*
2012-05-05 15:19:01 +00:00
expand Expand snippet (default action)
2012-02-02 04:33:35 +00:00
edit Edit snippet
preview View snippet definition
2012-10-30 01:51:33 +00:00
==============================================================================
FAQ *neosnippet-faq*
2012-11-15 23:05:14 +00:00
Q: What if I want to expand a snippet trigger after (, [, " etc...:
2012-10-30 01:51:33 +00:00
2012-11-03 03:33:18 +00:00
A: You should use "options word" in the snippet definition. This changes the
2012-11-15 23:05:14 +00:00
expansion behavior to a word boundary.
2012-10-30 01:51:33 +00:00
>
snippet date
options word
`strftime("%d %b %Y")`
<
2012-11-03 03:33:18 +00:00
Q: Why does neosnippet not indent the expanded snippet?
2012-10-30 01:58:26 +00:00
A: You should use "options indent" in the snippet definition. In default,
neosnippet doesn't indent the expanded line.
2012-10-30 01:58:26 +00:00
Q: What if Neosnippet conflicts with |LustyJuggler|.
2012-10-30 02:45:29 +00:00
http://www.vim.org/scripts/script.php?script_id=2050
A: Please try below settings:
Note: But you must unmap the mappings in select mode manually.
2012-10-30 02:45:29 +00:00
>
let g:neosnippet#disable_select_mode_mappings = 0
<
Q: Error using snipmate-snippets
https://github.com/Shougo/neosnippet/issues/86
A: Please try below settings. It defines snipMate function.
>
let g:neosnippet#enable_snipmate_compatibility = 1
<
2012-02-02 04:33:35 +00:00
==============================================================================
2012-09-27 12:17:07 +00:00
CHANGELOG *neosnippet-changelog*
2013-02-17 04:10:41 +00:00
2013-02-17
- Improved :NeoSnippetEdit.
2013-02-17 05:58:57 +00:00
- Added neosnippet/runtime and neosnippet/user sources.
2013-02-17 07:11:21 +00:00
- Added unite__new_candidate action.
2013-02-17 04:10:41 +00:00
2013-02-16 04:13:32 +00:00
2013-02-16
- Added sh snippet.
2013-02-16 05:35:09 +00:00
- Added html snippet.
- Delete simple markers when InsertLeave.
- Fixed s:get_sources_filetypes() error.
2013-02-16 04:13:32 +00:00
2013-02-03 23:36:52 +00:00
2013-02-03
- Improved php snippets.
2013-02-01 02:47:59 +00:00
2013-02-01
- Added vim snippets.
2013-01-29 23:03:53 +00:00
2013-01-30
- Added autoload snippet in Vim snip.
2013-01-22 01:48:34 +00:00
2013-01-22
- Added NeoBundleLazy snippet.
2013-01-20 02:59:32 +00:00
2013-01-20
- Lazy initialization.
2013-01-13
- Added neosnippet#expandable_or_jumpable().
2013-01-07
- Changed neosnippet#expandable() behavior.
2013-01-02 04:53:58 +00:00
2013-01-02
- Improved initialization timing.
2012-12-21 10:19:23 +00:00
2012-12-21
- Improved tex snippets.
2012-12-13
- Skip neocomplcache completion when expand or jump snippets.
2012-12-13 07:52:58 +00:00
- Fixed expand target behavior.
2012-11-08 22:55:40 +00:00
2012-11-09
- Improved syntax error.
2012-11-08 22:58:17 +00:00
- Fixed error in java snippet.
2012-11-08 23:47:12 +00:00
- Improved snippet rank.
2012-11-10 01:47:14 +00:00
- Improved keyword filter behavior.
2012-11-09 05:25:32 +00:00
- Fixed convert description.
2012-11-08 22:55:40 +00:00
2012-11-08 02:56:07 +00:00
2012-11-07
- Fixed s:indent_snippet().
2012-11-06 05:56:29 +00:00
2012-11-06
- Improved default tex snippets.
2012-11-06 06:28:54 +00:00
- Fixed expand target.
2012-11-06 05:56:29 +00:00
2012-11-05 03:01:14 +00:00
2012-11-05
- Fixed for comment string.
2012-11-05 03:11:25 +00:00
- Fixed snippet parser.
2012-11-05 07:41:01 +00:00
- Improved syntax description.
2012-11-05 07:59:39 +00:00
- Changed spaces behavior.
2012-11-05 03:01:14 +00:00
2012-11-04 11:47:54 +00:00
2012-11-04
- Improved completion behavior.
2012-11-03 03:33:18 +00:00
2012-11-03
- Refactored documentation.
2012-11-03 03:40:08 +00:00
- Added :NeoSnippetSource.
2012-11-03 05:08:11 +00:00
- Refactored parse routine.
2012-11-03 06:35:27 +00:00
- Added regexp syntax.
2012-11-03 03:33:18 +00:00
2012-11-02
- Added g:neosnippet#enable_snipmate_compatibility option.
- Used partial match for neocomplcache completion.
2012-11-02 02:44:35 +00:00
- Fixed for neocomplcache.
2012-11-02 05:39:23 +00:00
- Improved partial match behavior.
2012-11-02 08:54:48 +00:00
- Added python snippets.
2012-11-01 02:18:58 +00:00
2012-11-01
- Fixed snippet mirror behavior.
2012-11-01 02:26:40 +00:00
- Fixed substitute of target.
2012-11-01 02:29:37 +00:00
- Fixed convert description.
2012-11-01 09:44:37 +00:00
- Improved java snippets.
2012-11-01 02:18:58 +00:00
2012-10-31 02:10:56 +00:00
2012-10-31
- Improved indent_snippet().
- Added <Plug>(neosnippet_start_unite_snippet_target).
2012-10-31 02:10:56 +00:00
2012-10-29 20:09:50 +00:00
2012-10-30
- Implemented commented placeholder.
2012-10-29 20:11:23 +00:00
- Improved python snippets.
2012-10-29 20:18:59 +00:00
- Fixed for alias.
2012-10-29 22:45:46 +00:00
- Implemented targetted placeholder.
- Improved documentation.
2012-10-30 01:51:33 +00:00
- Added FAQ section.
2012-10-30 01:58:26 +00:00
- Added indent option.
- Added <Plug>(neosnippet_register_oneshot_snippet).
2012-10-30 08:53:14 +00:00
- Refactored snippets files.
2012-10-29 20:09:50 +00:00
2012-10-29 02:22:37 +00:00
2012-10-29
- Improved parse of snippets file.
2012-10-29 02:27:22 +00:00
- Improved syntax of markers.
2012-10-29 03:28:33 +00:00
- Improved clear select mode mappings.
2012-10-29 10:27:18 +00:00
- Added get_selected_text().
2012-10-29 02:22:37 +00:00
2012-10-28 09:47:26 +00:00
2012-10-28
- Improved snipMate compatibility.
2012-10-28 09:58:55 +00:00
- Improved expand behavior.
2012-10-28 10:15:58 +00:00
- Improved filter behavior.
2012-10-28 09:47:26 +00:00
2012-10-27 03:20:00 +00:00
2012-10-27
- Fixed for :SnippetEdit.
- Improved g:neosnippet#disable_select_mode_mappings behavior.
2012-10-27 03:20:00 +00:00
2012-10-26 01:46:05 +00:00
2012-10-26
- Improved javascript snippet file.
2012-10-25 01:50:25 +00:00
2012-10-25
- Deleted sandbox execution.
2012-10-23 02:00:22 +00:00
2012-10-23
- Improved neosnippet#util#expand().
2012-10-21 08:51:07 +00:00
2012-10-21
- Added options head.
2012-10-21 09:03:10 +00:00
- Added options word.
2012-10-21 11:48:02 +00:00
- Improved options word behavior.
2012-10-21 12:13:26 +00:00
- Use head instead of prev_word.
2012-10-21 08:51:07 +00:00
2012-10-20
- Improved scala snip.
2012-10-21 02:16:15 +00:00
- Added haskell snip.
2012-10-21 02:48:13 +00:00
- Added vim/vital snip.
2012-10-19 00:00:36 +00:00
2012-10-19
- Fixed syntax highlight.
2012-10-19 02:02:08 +00:00
- Improved documentation.
2012-10-19 07:07:15 +00:00
- Search snippets recursively.
2012-10-19 09:31:55 +00:00
- Fixed make cache behavior.
2012-10-19 00:00:36 +00:00
2012-10-18 07:31:45 +00:00
2012-10-18
- Fixed s:get_sources_list().
- Added unite__new_candidate action in snippet source.
- Fixed menu pattern.
2012-10-16 23:19:37 +00:00
2012-10-17
- Fixed alias problem.
2012-10-16 23:27:52 +00:00
- Improved escape placeholder.
2012-10-16 23:19:37 +00:00
2012-10-16 05:06:45 +00:00
2012-10-15
- Improved lua snip.
2012-10-16 06:05:24 +00:00
- Improved c++ snip.
2012-10-16 05:06:45 +00:00
2012-10-07
- Improved vim snip.
2012-10-14 01:11:05 +00:00
- Improved c snip.
2012-10-06 07:22:36 +00:00
2012-10-06
- Improved indent snippet behavior.
2012-10-06 08:16:56 +00:00
- Fixed substitute marker.
2012-10-06 11:19:44 +00:00
- Fixed for E749.
2012-10-06 07:22:36 +00:00
2012-10-04 01:22:35 +00:00
2012-10-04
- Refactored snippets filter.
2012-10-04 03:35:07 +00:00
- Changed :NeoSnippetEdit behavior.
2012-10-04 04:22:37 +00:00
- Added scala snip.
2012-10-04 05:28:37 +00:00
- Fixed s:get_cursor_snippet().
- Changed g:neosnippet#disable_runtime_snippets behavior.
2012-10-04 09:49:16 +00:00
- Changed prev_word behavior.
2012-10-04 01:22:35 +00:00
2012-10-01
- Deleted neosnippet#force_expandable().
2012-10-01 04:25:38 +00:00
- Improved python snippets.
2012-09-30 08:04:46 +00:00
2012-09-30
- Changed runtime directory.
2012-09-30 08:06:28 +00:00
- Vitalized.
- Deleted neocomplcache#util functions.
2012-09-30 08:17:31 +00:00
- Refactored variables.
- Deleted s:get_cursor_keyword_snippet().
2012-09-30 08:33:50 +00:00
- Improved for filetype.
2012-09-30 08:45:41 +00:00
- Improved filetype complete.
2012-09-30 09:13:49 +00:00
- Improved documentation.
- Changed neocomplcache source behavior.
2012-09-30 10:10:25 +00:00
- Renamed commands.
2012-09-30 14:16:26 +00:00
- Fixed snippet source errors.
2012-09-30 08:04:46 +00:00
2012-09-27 12:17:07 +00:00
2012-09-27
- Ver.3 development is started.
- Renamed documentation.
2012-09-27 12:30:33 +00:00
- Renamed keymappings.
2012-09-27 12:17:07 +00:00
------------------------------------------------------------------------------
ChangeLog 2.0:
2012-09-26 22:38:16 +00:00
2012-09-27
- Improved add placeholder behavior.
- Fixed wrong indentation when 'expandtab'.
2012-02-02 04:33:35 +00:00
2012-09-23 04:45:38 +00:00
2012-09-23
- Fixed substitute tab character.
2012-09-23 04:48:35 +00:00
- Improved cursor position.
2012-09-23 05:30:02 +00:00
- Fixed column in select mode.
- Added lua snip.
- Improved javascript snip.
2012-09-23 05:55:13 +00:00
- Improved ruby snip.
2012-09-23 04:45:38 +00:00
2012-09-06
- Added neocomplcache__convertable attribute.
2012-08-30
- Changed <Plug>(neocomplcache_snippets_expand) behavior.
2012-08-27
- Fixed neocomplcache#sources#snippets_complete#force_expandable().
2012-08-02 02:11:44 +00:00
2012-08-02
- Improved caching snippet files.
2012-06-06
- Added neocomplcache#sources#snippets_complete#get_snippets_dir().
2012-06-02 00:53:35 +00:00
2012-06-02
- Fixed exapnd indentation.
2012-05-17 13:16:04 +00:00
2012-05-16
- Added ftdetect file.
2012-05-11 23:41:49 +00:00
2012-05-12
- Improved c snip.
2012-05-03 01:59:56 +00:00
2012-05-03
- Released ver.2.0.
2012-04-05 00:53:52 +00:00
2012-04-05
- Fixed nested placeholder problem.
2012-03-23 03:14:13 +00:00
2012-03-23
- Fixed substitute pattern bug.
2012-03-18 15:56:24 +00:00
2012-03-19
- Fixed substitute marker.
2012-03-18 15:39:35 +00:00
2012-03-18
- Fixed for expandtab.
2012-03-17 13:53:56 +00:00
2012-03-17
- Fixed for echodoc.
2012-03-15 15:06:21 +00:00
2012-03-16
- Fixed snippets indentation.
2012-03-15
- Improved search snippet markers behavior.
2012-03-15 14:26:21 +00:00
- Don't conceal default codes.
2012-03-13 15:39:45 +00:00
2012-03-14
- Refactored expand snippet behavior.
2012-03-13 23:49:57 +00:00
- Fixed expand bug.
2012-03-14 00:35:41 +00:00
- Refactored substitute patterns.
2012-03-14 00:43:33 +00:00
- Changed marker patterns.
2012-03-13 15:39:45 +00:00
2012-03-08
- Use shiftwidth instead of softabstop.
2012-03-08 09:38:58 +00:00
- Fixed plugin indentation problem.
2012-03-06 23:19:01 +00:00
2012-03-07
- Added snippet source.
2012-03-06 23:39:08 +00:00
- Fixed snippet source behavior.
2012-03-07 01:05:00 +00:00
- Improved snippet source.
2012-03-06 23:19:01 +00:00
2012-03-06 08:04:37 +00:00
2012-03-06
- Improved ftplugin.
2012-03-03
- Added neocomplcache#sources#snippets_complete#force_expandable() and
neocomplcache#sources#snippets_complete#jumpable().
2012-02-25 14:05:10 +00:00
2012-02-25
- Improved split().
2012-02-24 04:42:12 +00:00
2012-02-24
- Improved a bit.
2012-02-22 03:59:57 +00:00
2012-02-22
- Fixed prev_word behavior.
2012-02-21 04:07:46 +00:00
2012-02-21
- Improved documentation.
2012-02-05 01:24:59 +00:00
2012-02-05
- Fixed variable name.
2012-02-02 04:33:35 +00:00
2012-02-02
- Initial version.
2012-02-02 09:16:06 +00:00
- Improved documentation.
2012-02-02 04:33:35 +00:00
==============================================================================
2013-01-11 14:59:59 +00:00
vim:tw=78:ts=8:ft=help:norl:noet:fen:noet: