GithubHelp home page GithubHelp logo

af / vim-snippets Goto Github PK

View Code? Open in Web Editor NEW

This project forked from honza/vim-snippets

0.0 2.0 0.0 868 KB

vim-snipmate default snippets (Previously snipmate-snippets)

License: MIT License

Vim Script 100.00%

vim-snippets's Introduction

Snipmate & UltiSnip Snippets

This repository contains snippets files for various programming languages.

It is community-maintained and many people have contributed snippet files and other improvements already.

Contents

  • snippets/*: snippets using snipmate format
  • UltiSnips/*: snippets using UltiSnips format

Snippet engines supporting vim-snippets

There are different forks of snippet engines which allow the user to insert snippets by typing the name of a snippet hitting the expansion mapping.

There tries to be a more comprehensive list (which still is incomplete) here: http://vim-wiki.mawercer.de/wiki/topic/text-snippets-skeletons-templates.html

UltiSnips has additional features such as high speed, nesting snippets, expanding snippets in snippets and offers powerful transformations on text in snippets (like visual selections or placeholder texts).

Which one to use? If you have python give SirVer/ultisnips a try because its fast and has the most features.

If you have VimL only (vim without python support) your best option is using garbas/vim-snipmate and cope with the minor bugs found in the engine.

Installation

First be aware that there are many options, see "Snippet engines" above. Second be aware than there are tons of plugin managers which is why Marc Weber thinks that it doesn't make sense to repeat the same repetitive information everywhere.

Recommended way: vim-addon-manager (because Marc Weber wrote it for exactly this reason, it supports simple dependency management). Eg you're done by this line in your .vimrc:

" assuming you want to use snipmate snippet engine
ActivateAddons vim-snippets snipmate

vim-pi Is the place to discuss plugin managers and repository resources.

About how to install snipate see snipmate@garbas

(Bundle, Pathogen, git clone - keywords to make people find this link by ctrl-f search) I know that I should be reading the docs of the snippet engine, just let me copy paste into my .vmirc: (See this pull request)[https://github.com/honza/vim-snippets/pull/307/files].

TROUBLE

If you still have trouble getting this to work create a github ticket, ask on irc or the mailinglist.

Policies / for contributors

Some snippets are useful for almost all languages, so let's try to have the same triggers for them:

if : if without else
ife: if $1 else $2
eif : else if ($1) { .. }
el  : else ..
wh  : while (cond) ...

Don't add useless placeholder default texts like

if (${1:condition}){
  ${2:some code here}
}

instead use:

if (${1}){
  ${2}
}

Exception: Functions which are used less often, such as Vim's matchall(), matchstr() functions which case hints may be helpful to remember order. In the VimL case get vim-dev plugin which has function completion

Thus for conditions (while, if ..) and block bodies just use ${N} - Thanks

Open questions: What about one line if ee then .. else .. vs if \n .. then \n ... \n else \n .. ? Which additional policies to add? Discuss at: honza#230

Related repositories

We also encourage people to maintain sets of snippets for particular use cases so that all users can benefit from them. People can list their snippet repositories here:

 * https://github.com/rbonvall/snipmate-snippets-bib (snippets for BibTeX files)
 * https://github.com/sudar/vim-arduino-snippets (snippets for Arduino files)
 * https://github.com/zedr/zope-snipmate-bundle.git (snippets for Python, TAL and ZCML)
 * https://github.com/bonsaiben/bootstrap-snippets (snippets for Twitter Bootstrap markup, in HTML and Haml)

Installation using VAM: "github:rbonvall/snipmate-snippets-bib"

Future - ideas - examples

overview snippet engines If you have ideas you can add them to that list of "snippet engine features by example".

Historical notes

vim-snipmate was originally started by Michael Sanders who has now unfortunately abandoned the project. Rok Garbas is now maintaining a fork of the project in hopes of improving the existing code base.

Versions / dialects / ..

There are some issues, such as newer language versions may require other snippets than older. If this exists we currently recommend doing this:

add snippets/ruby.snippets (common snippets) add snippets/ruby-1.8.snippets (1.8 only) add snippets/ruby-1.9.snippets (1.9 only)

then configure github.com/garbas/vim-snipmate this way:

let g:snipMate = {}
let g:snipMate.scope_aliases = {}
let g:snipMate.scope_aliases['ruby'] = 'ruby,ruby-rails,ruby-1.9'

If it happens that you work on a project requiring ruby-1.8 snippets instead, consider using vim-addon-local-vimrc and override the filetypes.

Well - of course it may not make sense to create a new file for each ruby-library-version triplet. Sometimes postfixing a name such as

migrate_lib_20_down
migrate_lib_20_up

will do it then if syntax has changed.

Language maintainers

No one can really be proficient in all programming languages. If you would like to maintain snippets for a language, please get in touch.

Notes: People are interested in snippets - and their interest may wane again. This list is kept up-to-date on a best effort basis.

Contributing notes

Until further work is done on vim-snipmate, please don't add folding markers into snippets. vim-snipmate has some comments about how to patch all snippets on the fly adding those.

Because UltiSnips reads snipmate-snippets too there is no need to duplicate all snippets - only those snippets who use advanced UltiSnips features should be duplicated in UltiSnips.

Currently all snippets from UltiSnips have been put into UltiSnips - some work on merging should be done (dropping duplicates etc)

License

Just as the original snipMate plugin, all the snippets are licensed under the terms of the MIT license.

vim-snippets's People

Contributors

1334 avatar abroder avatar alderz avatar dsiw avatar erikw avatar heytrav avatar honza avatar hzx avatar iurifq avatar jb55 avatar juanpabloaj avatar kevicency avatar kronn avatar manchikha avatar marcweber avatar mclee avatar mengzhuo avatar michaelthessel avatar misaflo avatar mwcz avatar phmongeau avatar sirver avatar soplakanets avatar swsnr avatar taq avatar theocrite avatar thisgeek avatar torbjornvatn avatar tormaroe avatar yydonny avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.