DEV Community

Cover image for The Easiest Way To Share And Store Snippets of Code
Julien for Codiga

Posted on • Updated on

The Easiest Way To Share And Store Snippets of Code

Software development should be a community where peers can share reusable snippets of code with one another in the spirit of saving each other time and stress.

Seasoned engineers know the importance of code snippets when embarking on a new project, or even making improvements to existing ones. Code snippets are a developer’s best friend, as they allow you to significantly reduce the time it takes to build a project. If there is already an existing piece of reusable code out there, why wouldn’t you use it? It’s a no brainer, but finding accurate and up-to-date code poses a lot of risks.

Code sourced online may not be the most efficient way to go about this, because you have to spend time searching for exactly what you're looking for. And even if you find it, it can be annoying having to jump between multiple working environments.

Codiga’s latest addition to their portfolio of features, Coding Assistant, is a hub for users to share code snippets with each other in the hopes of saving them some much-needed time.

Ease of use is top of mind for all of Codiga’s tools, and this helpful program can integrate with your current workflow via Codiga IDE Plugins for VS Code, IntelliJ and Chrome. This means you can create, share and use code snippets directly in your IDE environment. One plugin supports all languages; Apex, C, C++, Dart, Docker, Go, Java, Javascript, Kotlin, PHP, Python, Ruby, Scala, Shell Script, Terraform, Typescript, and YAML.

Within Coding Assistant, code snippets are known as Recipes. Users can create and store private or public Recipes in one place that can easily be shared and reused, either by the developer themselves or with a greater team. Regularly adding and using Recipes leads to more consistency on a project, and helps teams ensure they are not doing the same work for a project.

Adding Recipes on Coding Assistant will not only make your workday a lot more efficient, but it also helps other Codiga users have access to the foundations they need to be successful.

Sharing snippets on Codiga is a very seamless process thanks to their IDE plugins that allow you to share Recipes that can be used across multiple IDEs instantly.

VS Code

Integrating the Codiga VS Code Plugin is a quick process, and is done in the plugin section. Once you download the Codiga plugin from the VS Marketplace, setting up takes a matter of minutes. It’s vital to remember to link your Codiga account using an API token, done in the settings section. This gives you access to all of the public Recipes within the Codiga network.

Then, when you are ready to share a code snippet, all you have to do is highlight the code, right click, and select create recipe. You’ll be prompted to add a name, description and some other details, but the most important component here is filling in the keywords. Keywords associated with the Recipe are what populates a Recipe in an IDE, so ensuring the code snippet is tagged correctly is essential.

Create a snippet from VS Code

Once you have added a Recipe and want to reuse it, or you want to use another code snippet that has been added by another Codiga user, first you need to subscribe to a Recipe on the Codiga marketplace. You can search for code snippets based on name, language or the keyword associated with it.

Once you have subscribed, all you have to do to populate it in your IDE is type control + shift + c to open the snippet folder. Then, type the keyword and select the snippet you want, and it will instantly appear!

JetBrains

The Codiga Jetbrains plugin is easily downloaded from the Jetbrains Marketplace, and is available to install with all Jetbrains plugins including IntelliJ, PHPStorm, PyCharm and more.

Create a snippets from JetBrains

From there, it’s a similar straightforward process to add a Recipe, like VS Code. Select the code, right click, and fill out the info( don’t forget those keywords!).

Using a Recipe has a similar command to VS Code with a slight variation; control + ALT + c and then enter the keyword to select the Recipe you want to use.

Google Chrome

Codiga’s Coding Assistant also allows you to create code snippets directly in Chrome. The Chrome integration can be downloaded from the Chrome Store and is compatible with all Chrome-based browsers. This allows you to create a Recipe by highlighting and selecting a piece of code on any Chrome browser from around the web. From there, all you need to do is right click and select “create Codiga Recipe '' and you’ll be directed to the page to determine the specifics of your Recipe.

To Conclude

Code snippets are essential for developers productivity, and sanity! Codiga’s Coding Assistant makes utilizing code snippets in multiple languages and various IDEs a simple and straightforward process. Spend less time searching for code snippets and more time focusing on the elements of your project that require your full attention.

To become a member of Codiga’s platform and have access to the Coding Assistant tool, visit codiga.io now.

Links

Discussion (0)