{"id":20446186,"url":"https://github.com/aerijo/snippets-plus","last_synced_at":"2025-04-13T00:45:10.141Z","repository":{"id":52108321,"uuid":"280407044","full_name":"Aerijo/snippets-plus","owner":"Aerijo","description":"Redesigned snippets for Atom","archived":false,"fork":false,"pushed_at":"2021-05-07T11:01:57.000Z","size":669,"stargazers_count":6,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-13T00:45:02.674Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Aerijo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-17T11:29:00.000Z","updated_at":"2021-12-15T09:55:11.000Z","dependencies_parsed_at":"2022-08-22T16:00:28.496Z","dependency_job_id":null,"html_url":"https://github.com/Aerijo/snippets-plus","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aerijo%2Fsnippets-plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aerijo%2Fsnippets-plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aerijo%2Fsnippets-plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aerijo%2Fsnippets-plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aerijo","download_url":"https://codeload.github.com/Aerijo/snippets-plus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650420,"owners_count":21139672,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T10:18:22.707Z","updated_at":"2025-04-13T00:45:10.121Z","avatar_url":"https://github.com/Aerijo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.com/Aerijo/snippets-plus.svg?branch=master)](https://travis-ci.com/Aerijo/snippets-plus)\n\n# Snippets-plus\n\nThis is a reimagining of the original `snippets` package. It introduces new features such as variables and advanced formatting.\n\n## Features\n\nSnippets as in the `snippets` package, plus:\n\n- Status bar indicator for when in snippets mode\n- Command to leave snippets mode\n- Variables and named transformations\n- Conditional transformation replacements\n- Map snippets to keyboard shortcuts\n- Altered `$0` (end tab stop) semantics\n\nSee [the wiki](https://github.com/Aerijo/snippets-plus/wiki) for more in depth information.\n\n## Snippets\n\n### Syntax\n\nCheck [the wiki page](https://github.com/Aerijo/snippets-plus/wiki/Syntax) for snippet syntax.\n\n### Defining snippets\n\nSnippets can be provided by packages. Any `.cson` or `.json` file in a top level `snippets` directory will be searched. Users can also provide snippets directly through the `~/.atom/snippets.cson` file.\n\nThe structure is as follows:\n\n```coffee\nsource1:\n  name1:\n    prefix: \"foo\"\n    body: \"Hello world\"\n  name2:\n    prefix: \"bar\"\n    body: \"second snippet\"\n\nsource2:\n  name1:\n    prefix: \"foo\"\n    body: \"a snippet for a different scope\"\n```\n\nThe top level keys are _scope selectors_. These control what parts of a file the snippet can be expanded in. For example,\n\n- `.source.js` allows the snippet to be expanded in all JavaScript files\n- `.source.js,.source.ts` allows the snippet to be used in JS and TS files\n- `.source.js .string` only allows the snippet to expand in JS strings\n- `.string` allows the snippet in any string of any language\n\nYour file may have any number of these selectors. Note that because of how CSON and JSON work, all sibling keys must be unique. If you want to add multiple snippets to the same scope, make sure to do it under the same key. E.g.,\n\n```coffee\n# No good, two keys on the same object have the same value\n\".source.js\":\n  name1:\n    prefix: 'snippet1'\n    body: 'my first snippet'\n\n\".source.js\":\n  name2:\n    prefix: 'snippet2'\n    body: 'my next snippet'\n\n###############\n# Fixed\n\".source.js\":\n  name1:\n    prefix: 'snippet1'\n    body: 'my first snippet'\n\n  name2:\n    prefix: 'snippet2'\n    body: 'my next snippet'\n```\n\n- The `name` is a unique identifier for the snippet.\n- The `prefix` is a string that must be directly behind the cursor for this snippet to be expanded. It must be a single line, and no longer than 50 characters.\n- The body is what the snippet expands into, parsed as per the above _Syntax_ section.\n\nYou can also add `autocomplete-plus` attributes like `description` and `rightLabel`. They are not used by this package, but can make the autocomplete popup more descriptive.\n\nUntil now this is all the same as for the original snippets package. But this package supports a shorthand structure for when you don't care about naming snippets. If you don't declare a `prefix` key, then the snippet name will be used instead. And if the snippet declaration is a string, then it will be used as the body. So the following are all equivalent\n\n```coffee\n\".source.js\":\n  log:\n    prefix: \"log\",\n    body: \"console.log($1)$0\"\n\n################\n\n\".source.js\":\n  log:\n    body: \"console.log($1)$0\"\n\n################\n\n\".source.js\":\n  log: \"console.log($1)$0\"\n```\n\nAs with the original package, user snippets are watched and automatically updated when the file changes.\n\nThis package also provides a new snippet attribute `key`, which lets you associate a snippet with a keybinding. Doing this effectively skips using the prefix. Use `prefix: null` to prevent the snippet from having a prefix.\n\nThe key binding uses the same scope as the snippet to determine when it can be triggered, so you can have multiple snippets on the same key and the most specific match will be expanded.\n\n\u003c!-- TODO: Add support for a \"session\" level snippet, which is defined in a prompt and (optionally?) destroyed when the editor is closed --\u003e\n\n### Using\n\nTo expand a snippet, type it's prefix and run the `Snippets: Expand` command. This command is assigned the shortcut \u003ckbd\u003etab\u003c/kbd\u003e by default.\n\nThe selection of snippet to expand is follows:\n\n- Get set of snippets that can be expanded based on the cursor scope\n- Snippets with more specific selectors override ones that have the same prefix and are more general\n- User snippets override package snippets, and community package snippets override core package snippets\n- The snippet with the longest prefix that is completely matched by the text behind the cursor wins.\n\nSo if we had candidate prefixes `log` and `conlog`, then for the following text before the cursor:\n\n- `conlogq`: no snippet matches\n- `conlog`: picks the `conlog` snippet\n- `onlog`: picks the `log` snippet\n- `og`: no snippet matches\n\nTo goto the next tab stop, run `Snippets: Next Tab Stop` (again, \u003ckbd\u003etab\u003c/kbd\u003e by default) and to goto the previous run `Snippets: Previous Tab Stop` (\u003ckbd\u003eshift-tab\u003c/kbd\u003e by default). The keybindings can be disabled and replaced with your own.\n\nTechnical details on how expanded snippets behave can be found on [the wiki](https://github.com/Aerijo/snippets-plus/wiki/Syntax).\n\n### Legacy parsing mode\n\nI found I have many snippets that are defined like as follows\n\n```\n\\\\\\\\textbf{$1}$2\n```\n\nUnder the `snippets` package I never noticed a problem, but with this one you see it is still in snippets mode when you reach the `$2` stop. This can cause unexpected behaviour when you next press \u003ckbd\u003etab\u003c/kbd\u003e, and if you have the tab stops markers visible it will look weird too.\n\nBy default, this package will try to correct snippets like these. If this option is enabled, then if\n\n- the last part of the snippet (by location) is a simple tab stop,\n- the tab stop is the only one of its index, and\n- it is also the last (by index),\n\nthen it will be converted to a `$0` stop. So the above becomes\n\n```\n\\\\\\\\textbf{$1}$0\n```\n\nWhich behaves much better. Disable this mode if you want full control over your snippets.\n\n## Developing\n\n### Testing\n\nEasiest is to open the project in Atom and run `Window: Run Package Specs`.\n\nAlteratively run `atom test .` in the command line to run the test suite. Replace `atom` with `atom-beta` and `atom-nightly` as appropriate.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faerijo%2Fsnippets-plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faerijo%2Fsnippets-plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faerijo%2Fsnippets-plus/lists"}