PageRenderTime 28ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/sources_non_forked/vim-snippets/README.md

https://gitlab.com/Qaruk/vimrc
Markdown | 252 lines | 187 code | 65 blank | 0 comment | 0 complexity | a4c04bbf947af12d927acb77b8985f8f MD5 | raw file
  1. snipMate & UltiSnip Snippets
  2. ============================
  3. [![Build Status](https://travis-ci.org/honza/vim-snippets.svg)](https://travis-ci.org/honza/vim-snippets)
  4. This repository contains snippets files for various programming languages.
  5. It is community-maintained and many people have contributed snippet files and
  6. other improvements already.
  7. Contents
  8. --------
  9. - `snippets/*`: snippets using snipMate format
  10. - `UltiSnips/*`: snippets using UltiSnips format
  11. Snippet engines supporting vim-snippets
  12. ----------------------------------------
  13. There are different forks of snippet engines which allow the user to insert
  14. snippets by typing the name of a snippet hitting the expansion mapping.
  15. - [github.com/SirVer/ultisnips](https://github.com/SirVer/ultisnips):
  16. python, supports all snippets in this repo.
  17. - [github.com/garbas/vim-snipmate](https://github.com/garbas/vim-snipmate):
  18. VimL, snipmate-snippets, engine sometimes behaves strange. Supports
  19. snippets/*
  20. - [github.com/Shougo/neosnippet](https://github.com/Shougo/neosnippet.vim):
  21. VimL, supports snippets/* with some configuration.
  22. - [github.com/drmingdrmer/xptemplate](https://github.com/drmingdrmer/xptemplate):
  23. Totally different syntax, does not read snippets contained in this file, but
  24. it is also very powerful. It does not support vim-snippets (just listing it
  25. here for completeness)
  26. There tries to be a more comprehensive list (which still is incomplete) here:
  27. http://vim-wiki.mawercer.de/wiki/topic/text-snippets-skeletons-templates.html
  28. UltiSnips has additional features such as high speed, nesting snippets,
  29. expanding snippets in snippets and offers powerful transformations on text in
  30. snippets (like visual selections or placeholder texts).
  31. Which one to use? If you have python give
  32. [SirVer/ultisnips](https://github.com/SirVer/ultisnips) a try because its fast
  33. and has the most features.
  34. If you have VimL only (vim without python support) your best option is using
  35. [garbas/vim-snipmate](https://github.com/garbas/vim-snipmate) and cope with the
  36. minor bugs found in the engine.
  37. Q: Should "snipMate be deprecated in favour of UltiSnips"?
  38. A: No, because snipMate is VimL, and UltiSnips requires Python.
  39. Some people want to use snippets without having to install Vim with Python
  40. support. Yes - this sucks.
  41. One solution would be: Use snippets if they are good enough, but allow overriding them
  42. in UltiSnips. This would avoid most duplication while still serving most users.
  43. AFAIK there is a nested-placeholder branch for snipMate too. snipMate is still
  44. improved by Adnan Zafar. So maybe time is not ready to make a final decision yet.
  45. [github issue/discussion](https://github.com/honza/vim-snippets/issues/363)
  46. Vendor Snippets
  47. ---------------
  48. Additional library and framework snippets are available for UltiSnips users in
  49. the `UltiSnips/` directory. These files are removed from the default language
  50. namespaces to prevent them from all being loaded automatically. If there is a
  51. separate library, framework, or package you would like to support open a pull
  52. request!
  53. Additional snippets can be added to the current buffer with the
  54. `:UltiSnipsAddFiletypes` command followed by the snippet name without the
  55. "snippets" ending. For example, to add the JavaScript Jasmine snippets, run:
  56. `:UltiSnipsAddFiletypes javascript-jasmine`. To have this snippet loaded
  57. everytime a JavaScript file is opened or created you can add the command to your
  58. -`.vim/ftplugin/javascript.vim` file. Another way is to add
  59. `autocmd FileType js UltiSnipsAddFiletypes javascript-jasmine` in your `.vimrc`.
  60. For more see the UltiSnips docs (`:help UltiSnips`).
  61. Installation
  62. ------------
  63. First be aware that there are many options, see "Snippet engines" above.
  64. Second be aware than there are [tons of plugin managers](http://vim-wiki.mawercer.de/wiki/topic/vim%20plugin%20managment.html)
  65. which is why Marc Weber thinks that it doesn't make sense to repeat the same
  66. repetitive information everywhere.
  67. *Recommended way:*
  68. [vim-addon-manager](https://github.com/MarcWeber/vim-addon-manager) (because Marc Weber wrote it for exactly
  69. this reason, it supports simple dependency management). E.g. you're done by this
  70. line in your `.vimrc`:
  71. ```vim
  72. " assuming you want to use snipmate snippet engine
  73. ActivateAddons vim-snippets snipmate
  74. ```
  75. [vim-pi](https://bitbucket.org/vimcommunity/vim-pi/issue/90/we-really-need-a-web-interface)
  76. Is the place to discuss plugin managers and repository resources.
  77. About how to install snipMate see [snipmate@garbas](https://github.com/garbas/vim-snipmate)
  78. (Bundle, Pathogen, git clone - keywords to make people find this link by ctrl-f search)
  79. I know that I should be reading the docs of the snippet engine, just let me copy paste into my `.vimrc`:
  80. [See this pull request](https://github.com/honza/vim-snippets/pull/307/files).
  81. TROUBLE
  82. =======
  83. If you still have trouble getting this to work create a GitHub ticket, ask on
  84. IRC or the mailing list.
  85. Policies / for contributors
  86. ---------------------------
  87. Some snippets are useful for almost all languages, so let's try to have the same
  88. triggers for them:
  89. ```
  90. if : if without else
  91. ife: if $1 else $2
  92. eif : else if ($1) { .. }
  93. el : else ..
  94. wh : while (cond) ...
  95. ```
  96. Don't add useless placeholder default texts like:
  97. ```
  98. if (${1:condition}){
  99. ${2:some code here}
  100. }
  101. ```
  102. instead use:
  103. ```
  104. if (${1}){
  105. ${2}
  106. }
  107. ```
  108. Exception: Functions which are used less often, such as Vim's `matchall()`, `matchstr()`
  109. functions which case hints may be helpful to remember order. In the VimL case
  110. get vim-dev plugin which has function completion
  111. Thus for conditions (while, if ..) and block bodies just use ${N} - Thanks
  112. Open questions:
  113. What about one line if ee then .. else .. vs if \n .. then \n ... \n else \n .. ?
  114. Which additional policies to add?
  115. Discuss at: https://github.com/honza/vim-snippets/issues/230
  116. *folding markers*:
  117. Until further work is done on `vim-snipmate`, please don't add folding markers
  118. into snippets. `vim-snipmate` has some comments about how to patch all snippets
  119. on the fly adding those.
  120. Currently all snippets from UltiSnips have been put into UltiSnips - some work
  121. on merging should be done (dropping duplicates etc). Also see engines section above.
  122. Related repositories
  123. --------------------
  124. We also encourage people to maintain sets of snippets for particular use cases
  125. so that all users can benefit from them. People can list their snippet repositories here:
  126. * https://github.com/rbonvall/snipmate-snippets-bib (snippets for BibTeX files)
  127. * https://github.com/sudar/vim-arduino-snippets (snippets for Arduino files)
  128. * https://github.com/zedr/zope-snipmate-bundle.git (snippets for Python, TAL and ZCML)
  129. * https://github.com/bonsaiben/bootstrap-snippets (snippets for Twitter Bootstrap markup, in HTML and Haml)
  130. * https://github.com/sniphpets (advanced snippets for PHP, Symfony 2/3, Doctrine and etc.)
  131. Installation using VAM: https://github.com/MarcWeber/vim-addon-manager
  132. Future - ideas - examples
  133. -------------------------
  134. [overview snippet engines](http://vim-wiki.mawercer.de/wiki/topic/text-snippets-skeletons-templates.html)
  135. If you have ideas you can add them to that list of "snippet engine features by example".
  136. Historical notes
  137. ----------------
  138. [vim-snipmate][1] was originally started by [Michael Sanders][2] who has now
  139. unfortunately abandoned the project. [Rok Garbas][3] is now maintaining a
  140. [fork][4] of the project in hopes of improving the existing code base.
  141. Versions / dialects / ..
  142. ========================
  143. There are some issues, such as newer language versions may require other
  144. snippets than older. If this exists we currently recommend doing this:
  145. * add snippets/ruby.snippets (common snippets)
  146. * add snippets/ruby-1.8.snippets (1.8 only)
  147. * add snippets/ruby-1.9.snippets (1.9 only)
  148. then configure https://github.com/garbas/vim-snipmate this way:
  149. ```vim
  150. let g:snipMate = {}
  151. let g:snipMate.scope_aliases = {}
  152. let g:snipMate.scope_aliases['ruby'] = 'ruby,ruby-rails,ruby-1.9'
  153. ```
  154. If it happens that you work on a project requiring ruby-1.8 snippets instead,
  155. consider using `vim-addon-local-vimrc` and override the filetypes.
  156. Well - of course it may not make sense to create a new file for each
  157. ruby-library-version triplet. Sometimes postfixing a name such as
  158. ```
  159. migrate_lib_20_down
  160. migrate_lib_20_up
  161. ```
  162. will do it then if syntax has changed.
  163. Language maintainers
  164. --------------------
  165. No one can really be proficient in all programming languages. If you would like
  166. to maintain snippets for a language, please get in touch.
  167. Notes: People are interested in snippets - and their interest may wane again.
  168. This list is kept up-to-date on a best effort basis.
  169. * Elixir - [lpil](https://github.com/lpil), [iurifq](https://github.com/iurifq)
  170. * Falcon - [steveno](https://github.com/steveno)
  171. * HTML Django - [honza](http://github.com/honza)
  172. * Javascript - [honza](http://github.com/honza)
  173. * Markdown - [honza](http://github.com/honza)
  174. * PHP - [chrisyue](http://github.com/chrisyue)
  175. * Python - [honza](http://github.com/honza)
  176. * Ruby - [taq](http://github.com/taq)
  177. * Scala - [gorodinskiy](https://github.com/gorodinskiy)
  178. * Supercollider - [lpil](https://github.com/lpil)
  179. License
  180. -------
  181. Just as the original snipMate plugin, all the snippets are licensed under the
  182. terms of the MIT license.
  183. [1]: http://github.com/garbas/vim-snipmate
  184. [2]: http://github.com/msanders
  185. [3]: http://github.com/garbas
  186. [4]: http://github.com/garbas/vim-snipmate
  187. [7]: http://github.com/SirVer/ultisnips