If you didn’t know, Microsoft release an editor called Visual Studio Code and if you didn’t know, Visual Studio Code can handle Snippets and extensions. These Snippets can be created by Visual Studio and by the coding community. These can be simple modules to help coding or full languages. I have found a use to generate a snippet of code that I always use and so I have made this into a Visual Studio Code Snippet. Read on to find out what and how to use it.
What is it?
The Snippet is called CookieJs and by the title you can guess it is about cookies in JavaScript. This snippet produces 3 methods for running cookies. One is to set a cookie, one is to get a cookie and finally a method to check if an cookie exists. These three methods can be produced separately, plus also it can be produced as a JavaScript object.
How do you get it?
If you download Visual Studio Code first of course and you can do the following
- Install Visual Studio Code 0.10.1 or higher
- Launch Code
- From the command palette
Ctrl-Shift-P
(Windows, Linux) orCmd-Shift-P
(OSX) - Select Install Extension
- Type
CookieJs
- Choose the extension
- Reload Visual Studio Code
How do you use it?
So like most snippets, it is easy to use. You simply have to type in one of the 4 keywords and they will produce the respective snippets of code.
'cookieobj'
for full CookieJs object
'chkcookie'
for Check Cookie Function
'getcookie'
for Get Cookie Function
'setcookie'
for Set Cookie Function
A little snag that kept getting me is to remember to have the language setting set to JavaScript. To change this you need to click the Language Indicator, which is down in the bottom right hand of the status bar. This will bring up the Command Palette for Select Language Mode. You can read more about the languages here on Visual Studio Code site on Languages.
You can get this snippet and more from this link here to my CookieJs.