Further improvements in the snippet syntax chapter
This commit is contained in:
parent
1492d75709
commit
b0c36ab2c9
@ -374,8 +374,8 @@ EXAMPLES *neosnippet-examples*
|
|||||||
==============================================================================
|
==============================================================================
|
||||||
SNIPPET SYNTAX *neosnippet-snippet-syntax*
|
SNIPPET SYNTAX *neosnippet-snippet-syntax*
|
||||||
|
|
||||||
It is quite easy to create your own snippets starting with the example below.
|
It is quite easy to create your own snippets. Your can use the example below to
|
||||||
The snippet syntax is close to the one of |snipMate|.
|
get started.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@ -390,22 +390,25 @@ Example:
|
|||||||
endif
|
endif
|
||||||
<
|
<
|
||||||
|
|
||||||
|
The snippet syntax is close to the one of |snipMate|. Each snippet starts with
|
||||||
|
some keywords that define the name and modify the expansion and treatment of the
|
||||||
|
snippet.
|
||||||
|
|
||||||
Snippet Keywords:
|
Snippet Keywords:
|
||||||
|
|
||||||
- snippet [name] (Required)
|
- snippet [name] (Required)
|
||||||
|
|
||||||
Each snippet starts with the keyword "snippet". This keyword is directly
|
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
|
followed by the snippet name. The snippet name is used to expand the snippet.
|
||||||
the snippet.
|
|
||||||
|
|
||||||
- abbr [name] (Optional)
|
- abbr [name] (Optional)
|
||||||
|
|
||||||
You can define an abbreviation for the snippet. It will be displayed in
|
You can define an abbreviation for the snippet name. It will be displayed in
|
||||||
the drop down selection menu of neocomplcache.
|
the drop down selection menu of the neocomplcache plugin.
|
||||||
|
|
||||||
- alias [aliases] (Optional)
|
- alias [aliases] (Optional)
|
||||||
|
|
||||||
Alias names can be use as additional keywords to expand a snippet. You can
|
Alias names can be use as additional keywords to expand the snippet. You can
|
||||||
define multiple aliases using either spaces ' ' or commas ',' as separator.
|
define multiple aliases using either spaces ' ' or commas ',' as separator.
|
||||||
|
|
||||||
Example
|
Example
|
||||||
@ -430,8 +433,8 @@ Snippet Keywords:
|
|||||||
Options influence the snippet behavior. The possible values are:
|
Options influence the snippet behavior. The possible values are:
|
||||||
|
|
||||||
+ word This snippet expands by a word boundary. Note: To complete
|
+ word This snippet expands by a word boundary. Note: To complete
|
||||||
the trigger in snippets_complete, it must be a word character
|
the trigger with snippets_complete, it must be a word character
|
||||||
(digits, an alphabetical characters or "_").
|
(digits, alphabetical characters or "_").
|
||||||
|
|
||||||
>
|
>
|
||||||
snippet date
|
snippet date
|
||||||
@ -439,7 +442,7 @@ Snippet Keywords:
|
|||||||
`strftime("%d %b %Y")`
|
`strftime("%d %b %Y")`
|
||||||
<
|
<
|
||||||
|
|
||||||
+ head This snippet expands on the beginning of a line only.
|
+ head This snippet expands at the beginning of a line only.
|
||||||
Note: This is the same as "prev_word '^'" which is still
|
Note: This is the same as "prev_word '^'" which is still
|
||||||
there for backwards compatibility.
|
there for backwards compatibility.
|
||||||
|
|
||||||
@ -455,21 +458,21 @@ Snippet Keywords:
|
|||||||
to the indent of the line above the snippet after expansion.
|
to the indent of the line above the snippet after expansion.
|
||||||
|
|
||||||
The snippet itself starts below the part that contains the options, snippet
|
The snippet itself starts below the part that contains the options, snippet
|
||||||
aliases and kekywords, described above. It contains the snippet which gets
|
aliases and keywords, described above. It contains the snippet which gets
|
||||||
expanded and can contain several place holders. The placeholders are used as
|
expanded which can contain several placeholders. The placeholders are used as
|
||||||
jump points inside the snippet. There are several placeholder available and they
|
jump points while expanding the snippet. There are several placeholders available
|
||||||
provide diffrent functionality.
|
providing different functionality.
|
||||||
|
|
||||||
The structure of a placeholder can be:
|
The structure of a placeholder can be:
|
||||||
|
|
||||||
- ${number:placeholder text}
|
- ${number:placeholder text}
|
||||||
|
|
||||||
The number of a placeholder and the placeholder text are separated
|
The placeholder starts with a dollar sign "$". The number of a placeholder
|
||||||
by a ":". They are embraced by a pair of curly braces "{}". The
|
and the placeholder text are separated by a colon ":". They are surrounded
|
||||||
placeholder text is displayed after the snippet expansion and will be
|
by a pair of curly braces "{}". The placeholder text is displayed after
|
||||||
replaced by your text. If you jump over the snippet and do not insert
|
the snippet expansion and will be replaced by your text. If you jump over
|
||||||
any text in that position the placeholder text remains there. This can
|
the snippet and do not insert any text in that placeholder position the text
|
||||||
be used as a default value for a certain position.
|
remains there. This can be used as a default value for a certain position.
|
||||||
|
|
||||||
Example
|
Example
|
||||||
|
|
||||||
@ -482,7 +485,7 @@ The structure of a placeholder can be:
|
|||||||
|
|
||||||
- ${number:#:placeholder text}
|
- ${number:#:placeholder text}
|
||||||
|
|
||||||
In this type of placeholder the number is followed by the "#" character.
|
In this kind of placeholder the number is followed by the hash character "#".
|
||||||
If you jump over this placeholder and do not insert any text, the placeholder
|
If you jump over this placeholder and do not insert any text, the placeholder
|
||||||
text will be removed.
|
text will be removed.
|
||||||
|
|
||||||
@ -498,8 +501,8 @@ The structure of a placeholder can be:
|
|||||||
- ${number:TARGET}
|
- ${number:TARGET}
|
||||||
|
|
||||||
This is the target placeholder which is replaced by text from a visual
|
This is the target placeholder which is replaced by text from a visual
|
||||||
selection. Note: You need to expand your snippet with the key mapping below
|
selection. Note: You need to make a visual selection and expand your
|
||||||
for this to work.
|
snippet with the key mapping below for this to work.
|
||||||
|
|
||||||
|<Plug>(neosnippet_expand_target)|.
|
|<Plug>(neosnippet_expand_target)|.
|
||||||
|
|
||||||
@ -519,7 +522,7 @@ The structure of a placeholder can be:
|
|||||||
|
|
||||||
This is a placeholder which you can use as a simple jump position. This can be
|
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
|
useful if you edit a placeholder inside of some sort of brackets or environment
|
||||||
and after that want to go on behind that.
|
and want to go on behind it after that.
|
||||||
|
|
||||||
Example
|
Example
|
||||||
|
|
||||||
@ -535,7 +538,7 @@ The structure of a placeholder can be:
|
|||||||
- $number
|
- $number
|
||||||
|
|
||||||
This is a synchronized placeholder. Sometimes it is required to repeat a value
|
This is a synchronized placeholder. Sometimes it is required to repeat a value
|
||||||
in several places inside a snippet. If you set the number of this placeholder
|
in several positions 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
|
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
|
repeat its content. $1 is synchronized to ${1} and so on. $0 will be the final
|
||||||
jump placeholder.
|
jump placeholder.
|
||||||
@ -567,7 +570,7 @@ The structure of a placeholder can be:
|
|||||||
end
|
end
|
||||||
<
|
<
|
||||||
|
|
||||||
A placeholder value can not contain new lines. The snippet below isn't valid.
|
A placeholder value can not contain new lines. The snippet below is not valid.
|
||||||
|
|
||||||
>
|
>
|
||||||
snippet invalid
|
snippet invalid
|
||||||
@ -576,9 +579,9 @@ The structure of a placeholder can be:
|
|||||||
<
|
<
|
||||||
|
|
||||||
Vim has a built-in expression evaluation. You can also use this feature inside
|
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
|
of snippets if you use back ticks like in the example below. Here the "%:t"
|
||||||
expanded to the name of the current active file and the current time gets
|
gets expanded to the name of the current active file and the current time gets
|
||||||
inserted by the expansion of the strftime command.
|
inserted by expanding the output of the strftime command.
|
||||||
|
|
||||||
>
|
>
|
||||||
snippet header
|
snippet header
|
||||||
@ -586,14 +589,15 @@ inserted by the expansion of the strftime command.
|
|||||||
${2:Created at: `strftime("%B %d, %Y")`}
|
${2:Created at: `strftime("%B %d, %Y")`}
|
||||||
<
|
<
|
||||||
|
|
||||||
You can also nest the placeholders if you escape the special characters.
|
You can also nest placeholders if you escape the special characters.
|
||||||
|
|
||||||
>
|
>
|
||||||
snippet div
|
snippet div
|
||||||
<div ${1:id="${2:someid\}"}>${3}</div>${4}
|
<div ${1:id="${2:someid\}"}>${3}</div>${4}
|
||||||
<
|
<
|
||||||
|
|
||||||
In some cases you need to escape the "}" twice as the example below shows.
|
In some cases you need to escape the curly brace "}" twice as shown in the
|
||||||
|
example below.
|
||||||
|
|
||||||
>
|
>
|
||||||
snippet catch
|
snippet catch
|
||||||
|
Loading…
Reference in New Issue
Block a user