WrapIt
Wrap Contents With Specific Code
Labels text manipulation
Details
Installs
- Total 596
- Win 339
- Mac 155
- Linux 102
Sep 24 | Sep 23 | Sep 22 | Sep 21 | Sep 20 | Sep 19 | Sep 18 | Sep 17 | Sep 16 | Sep 15 | Sep 14 | Sep 13 | Sep 12 | Sep 11 | Sep 10 | Sep 9 | Sep 8 | Sep 7 | Sep 6 | Sep 5 | Sep 4 | Sep 3 | Sep 2 | Sep 1 | Aug 31 | Aug 30 | Aug 29 | Aug 28 | Aug 27 | Aug 26 | Aug 25 | Aug 24 | Aug 23 | Aug 22 | Aug 21 | Aug 20 | Aug 19 | Aug 18 | Aug 17 | Aug 16 | Aug 15 | Aug 14 | Aug 13 | Aug 12 | Aug 11 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Mac | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Linux | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Readme
- Source
- raw.githubusercontent.com
WrapIt
Sublime Text 3 plugin to easily wrap a text selection in predefined code blocks.
WhatFor?
- Want to surround a selection with brackets? Easy. Just WrapIt!
- Need to have these few lines inside an if-else block. It's fun. Just WrapIt!
- Like to join several functions into a class declaration? No problem. Just WrapIt!
- Want to … I think you get it! Just WrapIt! ;-)
Installation
Just use PackageControl. I am not going to explain here how to use it.
Usage
Wrapping
- Put your cursor anywhere, or select some text then hit alt+w.
- The quick panel will open giving you a range of code structure for wrapping your text with.
- Once you chose one, your text will rapidly get embedded into the selcted code structure.
- Like in any snippets you can use tab to move between different regions of that code to successively fill it.
Defining custom wrappers
By default WrapIt comes with templates for PHP, Python, JavaScript and JSON. You can extend the user settings file with custom templates for any syntax. Like so:
"definitions":[
{
"name":"Python",
"syntaxes": [
"Packages/Python/Python.sublime-syntax",
"Packages/Python 3/Python3.tmLanguage",
"Packages/Python Improved/PythonImproved.tmLanguage",
"Packages/MagicPython/grammars/MagicPython.tmLanguage"
],
"wrappers": [
{
"name": "if / else",
"description": "Wrap with: if - else block",
template":"\nif ${1}:\n\t<sel>\nelse:\n\t${2}"
}
]
}
]
- Copy definitions from to default to user settings file of the WrapIt package.
- Either extend an existing language or define a new one.
- “name” - name of language e.g. PYthon
- “syntaxed” - array of paths to .tmLanguage files for that language
- “wrappers” - array of objects for defining code blocks
- code block -
- “name” - name code block (label for quick panel)
- “descriptions” - one sentence descriptin of code block (sublabl for quick panel)
- “template” - template definition
Note: Both “name” and “template” must be filled or the respective code block will not be listed in the quick panel.
templating
<sel>
- where your selection should be placed\n
- new line\t
- indent for line, if preceeding tag, all lines of a multiline selection will get indented${x}
- regions for tab navigation, just like in snippets
Custom keybinding
As an alternative to the qick panel, commonly used wrapping can be bound to own key combination. In your user keybindings file, do:
{"keys": [ YOUR KEY COMBINATION ],
"command": "wrap_it",
"args": { NAME OF CODE BLOCK},
"context": [SPECIFY SYNTAX HERE]},
Contributors
- lattespirit: original idea, primordial version called sublime-wrapper.