Allound
A powerful extension for wrapping blocks of code in instructions or statements.
This extensions based on Surround by Mehmet Yatkı and rewritten for Python (other languages support soon).
Table Of Contents
Features
- Supports multi selections
- Custom wrapper snippets
- Sorts recently used snippets on top
- Assign shortcuts for each
wrapper snippets separately
Usage
After selecting the code block, you can
- Right click on selected code
- Or press CTRL(⌘) + SHIFT(⇧) + P
to get list of commands and pick one of them.
Hint
Each wrapper has a separate command so you can define keybindings for your favorite wrappers by searching allound.with.commandName
in the 'Keyboard Shortcuts' section.
Options
showOnlyUserDefinedSnippets
(boolean): Disables default snippets that comes with the extension and shows only used defined snippets.
showRecentlyUsedFirst
(boolean): Recently used snippets will be displayed on top.
Configuration
Each wrapper snippet config object is defined as IAlloundItem
like below:
interface IAlloundItem {
label: string; // must be unique
description?: string;
detail?: string;
snippet: string; // must be valid SnippetString
disabled?: boolean; // default: false
languageIds?: string[];
}
Editing or disabling existing wrapper functions
Go to "Settings" and search for "allound.with.commandName".
Example allound.with.if
:
{
"label": "if",
"description": "if $condition: ...",
"disabled": false,
"snippet": "if ${1:condition}:\n\t$TM_SELECTED_TEXT\n$0"
}
Adding new custom wrapper functions
Go to "Settings" and search for allound.custom
and edit it like below.
{
"allound.custom": {
// command name must be unique
"yourCommandName": {
// label must be unique
"label": "Your Snippet Label",
"description": "Your Snippet Description",
"snippet": "Something { $TM_SELECTED_TEXT$0 }", // <-- snippet goes here.
"languageIds": ["html", "javascript", "typescript", "markdown"]
},
// You can add more ...
}
}
Defining language-specific snippets
You can define snippets based on the document type by using languageIds
option.
Visit VSCode docs the full list of language identifiers.
1. Enabling a snippet for ALL languages
If you want to allow a snippet to work for all document types, simply REMOVE languageIds
option.
OR set it to ["*"]
as below:
{
"label": "if",
"description": "if $condition: ...",
"disabled": false,
"snippet": "if ${1:condition}:\n\t$TM_SELECTED_TEXT\n$0",
"languageIds": ["*"] // Wildcard allows snippet to work with all languages
}
2. Enabling a snippet for ONLY specified languages
If you want to allow a snippet to work with html
, typescript
and javascript
documents, you can use the example below.
{
"label": "if",
"description": "if $condition: ...",
"disabled": false,
"snippet": "if ${1:condition}: \n\t$TM_SELECTED_TEXT\n$0",
"languageIds": ["html", "typescript", "javascript"] // Allows snippet to work only with html, typescript, javascript
}
3. Disabling a snippet for ONLY specified languages
If you want to allow a snippet to work with all document types EXCEPT html
, typescript
and javascript
documents,
you can add -
(MINUS) sign as a prefix to the language identifiers (without a whitespace).
{
"label": "if",
"description": "if $condition: ...",
"disabled": false,
"snippet": "if ${1:condition}:\n\t$TM_SELECTED_TEXT\n$0",
"languageIds": ["*", "-html", "-typescript", "-javascript"]
}
Notes
- All command names and labels must be unique. If you do not provide a unique command name or label, your custom wrapper functions will override existing ones.
- You can redefine all snippets as long as you provide a valid
SnippetString
. Read More
Contribution
As always, I'm open to any contribution and would like to hear your feedback.
PS: Guide for running @vscode/test-web on WSL 2
Important Reminder
If you are planning to contribute to any open source project,
before starting development, please always open an issue and make a proposal first.
This will save you from working on features that are eventually going to be rejected for some reason.
Support
For support, email woidzeroo@gmail.com
License
Allound
is distributed under the terms of the MIT license.