Merge branch 'master' of github.com:Shougo/neosnippet
This commit is contained in:
commit
01a4e239f8
54
README.md
54
README.md
@ -1,10 +1,10 @@
|
|||||||
Neosnippet
|
Neosnippet
|
||||||
==========
|
==========
|
||||||
|
|
||||||
The Neosnippet plugin adds snippet support to vim. Snippets are
|
The Neosnippet plug-In adds snippet support to Vim. Snippets are
|
||||||
small templates for commonly used code that you can fill in on the
|
small templates for commonly used code that you can fill in on the
|
||||||
fly. To use snippets can increase your productivity in vim a lot.
|
fly. To use snippets can increase your productivity in Vim a lot.
|
||||||
The functionality of this plugin is quite similar to plugins like
|
The functionality of this plug-in is quite similar to plug-ins like
|
||||||
snipMate.vim or snippetsEmu.vim. But since you can choose snippets with the
|
snipMate.vim or snippetsEmu.vim. But since you can choose snippets with the
|
||||||
[Neocomplecache](https://github.com/Shougo/neocomplcache) interface, you might
|
[Neocomplecache](https://github.com/Shougo/neocomplcache) interface, you might
|
||||||
have less trouble using them, because you do not have to remember each snippet
|
have less trouble using them, because you do not have to remember each snippet
|
||||||
@ -13,17 +13,46 @@ name.
|
|||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
|
|
||||||
1. Install [Neocomplecache](https://github.com/Shougo/neocomplcache) first.
|
To install neosnippet and other Vim plug-ins it is recommended to use one of the
|
||||||
|
popular package managers for Vim, rather than installing by drag and drop all
|
||||||
|
required files into your `.vim` folder.
|
||||||
|
|
||||||
|
### Manual (not recommended)
|
||||||
|
|
||||||
|
1. Install the [Neocomplecache](https://github.com/Shougo/neocomplcache) plugin first.
|
||||||
2. Put files in your Vim directory (usually `~/.vim/` or
|
2. Put files in your Vim directory (usually `~/.vim/` or
|
||||||
`%PROGRAMFILES%/Vim/vimfiles` on Windows).
|
`%PROGRAMFILES%/Vim/vimfiles` on Windows).
|
||||||
|
|
||||||
|
### Vundle
|
||||||
|
|
||||||
|
1. Setup the [vundle](https://github.com/gmarik/vundle) package manager
|
||||||
|
2. Set the bundles for [Neocomplecache](https://github.com/Shougo/neocomplcache) and [Neobundle](https://github.com/Shougo/neosnippet)
|
||||||
|
|
||||||
|
```
|
||||||
|
Bundle 'Shougo/neocomplcache.git'
|
||||||
|
Bundle 'Shougo/neosnippet.git'
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Open up Vim and start installation with `:BundleInstall`
|
||||||
|
|
||||||
|
### Neobundle
|
||||||
|
|
||||||
|
1. Setup the [neobundle](https://github.com/Shougo/neobundle.vim) package manager
|
||||||
|
2. Set the bundles for [Neocomplecache](https://github.com/Shougo/neocomplcache) and [Neobundle](https://github.com/Shougo/neosnippet)
|
||||||
|
|
||||||
|
```
|
||||||
|
NeoBundle 'Shougo/neocomplcache.git'
|
||||||
|
NeoBundle 'Shougo/neosnippet.git'
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Open up Vim and start installation with `:NeoBundleInstall`
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
Here is an example `~/.vimrc` configuration for Neosnippet. It is assumed
|
This is an example `~/.vimrc` configuration for Neosnippet. It is assumes you
|
||||||
you already have Neocomplecache configured.
|
already have Neocomplecache configured. With the settings of the example, you
|
||||||
|
can use the following keys:
|
||||||
With these settings, you will use the following keys:
|
|
||||||
|
|
||||||
* `C-k` to select-and-expand a snippet from the Neocomplecache popup (Use `C-n`
|
* `C-k` to select-and-expand a snippet from the Neocomplecache popup (Use `C-n`
|
||||||
and `C-p` to select it). `C-k` can also be used to jump to the next field in
|
and `C-p` to select it). `C-k` can also be used to jump to the next field in
|
||||||
@ -46,12 +75,13 @@ endif
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If you want to use a different collection of snippets other than the built-in
|
If you want to use a different collection of snippets than the
|
||||||
ones, such as [Honza's Snippets](https://github.com/honza/snipmate-snippets), then you
|
built-in ones, then you can set a path to the snippets with
|
||||||
can set the `g:neosnippet#snippets_directory` variable.
|
the `g:neosnippet#snippets_directory` variable (e.g [Honza's
|
||||||
|
Snippets](https://github.com/honza/snipmate-snippets))
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
" Tell Neosnippet about these snippets
|
" Tell Neosnippet about the other snippets
|
||||||
let g:neosnippet#snippets_directory='~/.vim/bundle/snipmate-snippets/snippets'
|
let g:neosnippet#snippets_directory='~/.vim/bundle/snipmate-snippets/snippets'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -340,7 +340,7 @@ Example:
|
|||||||
snippet [name]
|
snippet [name]
|
||||||
abbr [abbreviation]
|
abbr [abbreviation]
|
||||||
alias [aliases]
|
alias [aliases]
|
||||||
prev_word '^'
|
options [options]
|
||||||
if ${1:condition}
|
if ${1:condition}
|
||||||
${2}
|
${2}
|
||||||
endif
|
endif
|
||||||
@ -362,7 +362,7 @@ Snippet Keywords:
|
|||||||
- alias [aliases] (optional)
|
- alias [aliases] (optional)
|
||||||
|
|
||||||
If you specify an alias it will be also used to expand a snippet. You can
|
If you specify an alias it will be also used to expand a snippet. You can
|
||||||
define multiple aliases either using the separators ' ' or ','.
|
define multiple aliases either using the separators ' ' or ','.
|
||||||
|
|
||||||
Example
|
Example
|
||||||
|
|
||||||
@ -370,11 +370,36 @@ Snippet Keywords:
|
|||||||
alias hoge hogera hogehoge
|
alias hoge hogera hogehoge
|
||||||
<
|
<
|
||||||
|
|
||||||
- prev_word [definition] (optional)
|
- options [options] (optional)
|
||||||
|
|
||||||
In the next line, here already starts the snippet which gets expanded. After
|
Options influece the snippet behavior. The possible options are:
|
||||||
snippet expansion you can jump to the placeholders and replace them with desired
|
|
||||||
text.
|
+ word This snippet expands by a word boundary. Note: To complete
|
||||||
|
the trigger in snippets_complete, it must be word(digits or
|
||||||
|
alphabet characters or "_") characters.
|
||||||
|
|
||||||
|
>
|
||||||
|
snippet date
|
||||||
|
options word
|
||||||
|
`strftime("%d %b %Y")`
|
||||||
|
<
|
||||||
|
|
||||||
|
+ head This snippet expands on the beginnign of a line only.
|
||||||
|
Note: This is the same as "prev_word '^'" which is still
|
||||||
|
there for backwards compatibility.
|
||||||
|
|
||||||
|
>
|
||||||
|
snippet if
|
||||||
|
if ${1:condition}
|
||||||
|
${2}
|
||||||
|
endif
|
||||||
|
<
|
||||||
|
|
||||||
|
+ indent Neosnippet indents the snippet after expansion to the same
|
||||||
|
column as the line above.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
The structure of a placeholder can be:
|
The structure of a placeholder can be:
|
||||||
|
|
||||||
@ -448,11 +473,11 @@ The structure of a placeholder can be:
|
|||||||
|
|
||||||
- $number
|
- $number
|
||||||
|
|
||||||
This is the synchronized placeholder. Sometimes it is required to repat a value in
|
This is a synchronized placeholder. Sometimes it is required to repat a value
|
||||||
several places inside a snippet. If you set the number of this placeholder
|
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
|
to the same number as one of the other placeholders in the snippet it will
|
||||||
repeat its content if you insert something. $1 is synchronized to ${1} and
|
repeat its content. $1 is synchronized to ${1} and so on. $0 will be the
|
||||||
so on. $0 will be the final jump placeholder.
|
final jump placeholder.
|
||||||
|
|
||||||
Example
|
Example
|
||||||
|
|
||||||
@ -516,13 +541,14 @@ E484, Vim(cmdname):{errmsg}"
|
|||||||
|
|
||||||
If you create a snippet file and prepend the filename with a "_" neosnippet
|
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
|
treats the snippets inside the file as global. This means that they will be
|
||||||
available for all file types (e.g _.snip). You can include snippet files with
|
available for all file types (e.g _.snip). You can include other snippet files
|
||||||
|
from within a snippet file with.
|
||||||
|
|
||||||
>
|
>
|
||||||
include c.snip
|
include c.snip
|
||||||
<
|
<
|
||||||
|
|
||||||
or if you want to include a whole directory with file type snippets.
|
Or if you want to include a whole directory with file type snippets.
|
||||||
|
|
||||||
>
|
>
|
||||||
include javascript/*
|
include javascript/*
|
||||||
@ -539,7 +565,6 @@ detects this. If you want to overwrite a snippet explicitly, please use:
|
|||||||
After that you can redefine the snippet. But this does not work if you include
|
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.
|
external snippet files. There will be no warning when snippets get overwritten.
|
||||||
|
|
||||||
|
|
||||||
Multi snippet feature in snipMate is available.
|
Multi snippet feature in snipMate is available.
|
||||||
Neosnippet substitutes trigger and descriptions spaces to '_'.
|
Neosnippet substitutes trigger and descriptions spaces to '_'.
|
||||||
>
|
>
|
||||||
@ -558,32 +583,20 @@ languages' indent files can not work very well (e.g.: PHP, Python).
|
|||||||
${2:// code...}
|
${2:// code...}
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
SNIPPET SYNTAX OPTIONS *neosnippet-snippet-syntax-options*
|
|
||||||
|
|
||||||
"options head" means this snippet is enabled only in line head.
|
|
||||||
Note: prev_word '^' is duplicated keyword.
|
|
||||||
|
|
||||||
"options word" means this snippet is expanded by word boundary.
|
|
||||||
Note: To complete the trigger in snippets_complete, it must be word(digits or
|
|
||||||
alphabet characters or "_") characters.
|
|
||||||
>
|
|
||||||
snippet date
|
|
||||||
options word
|
|
||||||
`strftime("%d %b %Y")`
|
|
||||||
<
|
|
||||||
"options indent" means neosnippet indents in expanded line.
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
UNITE SOURCES *neosnippet-unite-sources*
|
UNITE SOURCES *neosnippet-unite-sources*
|
||||||
|
|
||||||
*neosnippet-unite-source-snippet*
|
*neosnippet-unite-source-snippet*
|
||||||
snippet
|
snippet
|
||||||
The candidates are neosnippet snippets. The kinds are
|
The candidates of the snippet source are neosnippet snippets.
|
||||||
"snippet". Normally used in
|
and their kind is "snippet". You can use the snippet source
|
||||||
|<Plug>(neosnippet_start_unite_snippet)| mappings.
|
with the mapping |<Plug>(neosnippet_start_unite_snippet)|.
|
||||||
But you can execute it by ":Unite snippet".
|
But you can also execute it by ":Unite snippet". The snippet
|
||||||
You can edit snippet file in "edit" action.
|
source offers an edit action you can use to edit the snippet
|
||||||
Examples:
|
files.
|
||||||
|
|
||||||
|
Example:
|
||||||
>
|
>
|
||||||
imap <C-s> <Plug>(neosnippet_start_unite_snippet)
|
imap <C-s> <Plug>(neosnippet_start_unite_snippet)
|
||||||
<
|
<
|
||||||
@ -597,26 +610,26 @@ snippet *neosnippet-unite-action-snippet*
|
|||||||
==============================================================================
|
==============================================================================
|
||||||
FAQ *neosnippet-faq*
|
FAQ *neosnippet-faq*
|
||||||
|
|
||||||
Q: Don't expanded snippet trigger after (, [, " etc...:
|
Q: What if I do not like to expand a snippet trigger after (, [, " etc...:
|
||||||
|
|
||||||
A: You should use "options word" in snippet definition. "options word" means
|
A: You should use "options word" in the snippet definition. This changes the
|
||||||
this snippet is expanded by word boundary.
|
expansion behavior to a word boundary.
|
||||||
>
|
>
|
||||||
snippet date
|
snippet date
|
||||||
options word
|
options word
|
||||||
`strftime("%d %b %Y")`
|
`strftime("%d %b %Y")`
|
||||||
<
|
<
|
||||||
|
|
||||||
Q: Doesn't indent in expanded line:
|
Q: Why does neosnippet not indent the expanded snippet?
|
||||||
|
|
||||||
A: You should use "options indent" in snippet definition. In default,
|
A: You should use "options indent" in the snippet definition. In default,
|
||||||
neosnippet doesn't indent in expanded line.
|
neosnippet doesn't indent the expanded line.
|
||||||
|
|
||||||
Q: Neosnippet conflicts with |LustyJuggler|.
|
Q: What if Neosnippet conflicts with |LustyJuggler|.
|
||||||
http://www.vim.org/scripts/script.php?script_id=2050
|
http://www.vim.org/scripts/script.php?script_id=2050
|
||||||
|
|
||||||
A: Please try below settings:
|
A: Please try below settings:
|
||||||
Note: But you must unmap in select mode mappings manually.
|
Note: But you must unmap the mappings in select mode manually.
|
||||||
>
|
>
|
||||||
let g:neosnippet#disable_select_mode_mappings = 0
|
let g:neosnippet#disable_select_mode_mappings = 0
|
||||||
<
|
<
|
||||||
|
Loading…
Reference in New Issue
Block a user