bf-snippetmaster
Description
Why Use bf-snippetmaster?
- File-Specific Efficiency: While many snippet tools work on a language basis, bf-snippetmaster is tailored for specific files, increasing the relevance and usability of each snippet.
- Context-Driven Productivity: With file-specific snippets, you avoid cluttering your snippet library with irrelevant entries. Only relevant snippets for the specific file you're working on will appear, leading to cleaner and faster coding sessions.
- Adaptability: Are there specific structures or code fragments you tend to use only within particular files? bf-snippetmaster allows you to define snippets for those unique contexts.
- Organized Codebase: By focusing on the file level, bf-snippetmaster promotes organized, consistent, and clean code throughout your project.
Real-World Use Cases
- Config Files: Do you often find yourself typing the same structures in your .json, .xml or .yaml config files? Define these structures once as a snippet, and reuse them without the hassle.
- Templated Files: Do you have *.template files in your project where you commonly insert similar structures? Use bf-snippetmaster to create specific snippets for these files.
- Naming Conventions: Do you name your files following a specific pattern like *_test.py or *_config.json? bf-snippetmaster allows you to create snippets specifically for these file patterns.
- Code Review: For code reviewers, if there are specific comments or suggestions you frequently give for particular types of files, you can define these as snippets and save time during review.
Remember, the power of bf-snippetmaster lies in its ability to provide context-specific efficiency and productivity. With file-specific snippets, you have a powerful tool that adapts to your unique coding style and project needs!
Installation
- Launch Visual Studio Code.
- Go to the Extensions view by clicking on the square icon on the left sidebar or by pressing
Ctrl+Shift+X
.
- Search for "bf-snippetmaster" and click Install.
- Reload Visual Studio Code to activate the extension.
Available Commands
Here are the commands that bf-snippetmaster
provides:
SnippetMaster - Snippets folder
Opens the snippets folder in the file explorer, allowing you to easily add your snippet files.
SnippetMaster - info
Shows the current version of the installed extension
Usage
Snippets Folder
You can use the following command to quickly navigate to the snippets folder:
- Press
Ctrl+Shift+P
(Windows/Linux) or Cmd+Shift+P (Mac) to open the Command Palette.
- Search for "SnippetMaster -
Snippets folder
" and select it.
- The snippets folder will open in the file explorer, allowing you to easily add your snippet files.
Adding New Snippet Files
To add new snippet files for specific named files:
- Open the folder where you want to store your snippet files.
- Create a new file with the extension
.json
that corresponds to the file type you want to create snippets for. For example:
settings.xml.json
for custom snippets in settings.xml
.
config.json.json
for custom snippets in config.json
.
_.xml.json
for custom snippets in *.xml
.
_card.xml.json
for custom snippets in *card.xml
.
Examples
Example Snippet File (index.html.json)
For those working with HTML files, you might want to quickly insert some standard HTML structures, such as a navigation bar or a new section:
{
"navbar": {
"prefix": "navbar",
"body": [
"<nav>",
"<ul>",
"<li><a href=\"#home\">Home</a></li>",
"<li><a href=\"#about\">About</a></li>",
"<li><a href=\"#contact\">Contact</a></li>",
"</ul>",
"</nav>"
],
"description": "Insert a basic navigation bar"
},
"section": {
"prefix": "section",
"body": [
"<section id=\"$1\">",
"<h1>$2</h1>",
"<p>$3</p>",
"</section>"
],
"description": "Insert a new section with an ID, heading, and paragraph"
}
}
Example Snippet File (_test.py.json)
In Python testing files, you may want to quickly create a new unit test:
{
"unittest": {
"prefix": "unittest",
"body": [
"def test_${1:function_name}(self):",
" # Arrange",
" $2",
" # Act",
" $3",
" # Assert",
" self.assertEqual($4, $5)"
],
"description": "Create a new unit test following the Arrange-Act-Assert (AAA) pattern"
}
}
Example Snippet File (dbconfig.yaml.json)
For YAML configuration files, you might want to insert a database configuration block:
{
"dbconfig": {
"prefix": "dbconfig",
"body": [
"database:",
" host: $1",
" port: $2",
" user: $3",
" password: $4",
" database: $5"
],
"description": "Insert a new database configuration"
}
}
Author
Created by János Tigyi. Feel free to reach out on LinkedIn.