Cookie Consent by Free Privacy Policy Generator ๐Ÿ“Œ The few VS Code snippets that I use regularly

๐Ÿ  Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security



๐Ÿ“š The few VS Code snippets that I use regularly


๐Ÿ’ก Newskategorie: Programmierung
๐Ÿ”— Quelle: dev.to

Most of the time, I find myself forgetting the snippets I've set up just a week later. However, there are only a handful that are used almost daily in my workflow.

1. Directory name and file name in both camelCase and PascalCase

I've noticed that I often end up typing the name of a new component multiple times when creating components:

  1. Typing the name of the folder or file
  2. Typing the name of the actual function
  3. Typing the className

For example:

// MyAwesomeTitle.tsx
โ€ฆ
export function MyAwesomeTitle() {
  return <h1 className={styles.myAwesomeTitle}>
    โ€ฆ
  </h1>
}

To give my fingers a break, I've crafted some easy-to-remember snippets:

  • Dir: current directory/folder in PascalCase
  • dir: current directory/folder in camelCase
  • File: current file in PascalCase
  • file: current file in camelCase

These snippets are perfect when you're working within a directory and need to name your components consistently. The Dirname camelcase snippet, activated with the prefix dir, automatically converts the directory name to camelCase. Similarly, the Dirname pascalcase snippet, with the prefix Dir, converts to PascalCase. Same for file and File.

2. Shortcuts for class names

In addition to the above, I regularly use two more snippets that are incredibly handy when working with class names in React. The first one, cla makes assigning a CSS Module class name effortless.

The second snippet, cn, does the same but in addition provides a function call to concat class names.

  • cla: expands to className={styles.CURSOR}
  • cn: expands to className={cn(styles.CURSOR)}

Usage

The simplicity of these snippets makes them easy to remember and use.

To start using them just copy this json to your โ€ฆ/snippets/global.code-snippets.

๐Ÿ’ก You can easily open/create this file by ctrl+shift+P โ†’ Snippets: Configure User Snippets.

{
  "Dirname camelcase": {
    "prefix": "dir",
    "body": ["${TM_DIRECTORY/^.+[\\/\\\\]+(.*)$/${1:/camelcase}/}"]
  },
  "Filename camelcase": {
    "prefix": "file",
    "body": ["${TM_FILENAME_BASE/(.*)/${1:/camelcase}/}"]
  },
  "Dirname pascalcase": {
    "prefix": "Dir",
    "body": ["${TM_DIRECTORY/^.+[\\/\\\\]+(.*)$/${1:/pascalcase}/}"]
  },
  "Filename pascalcase": {
    "prefix": "File",
    "body": ["${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}"]
  },
  "className": {
    "scope": "typescriptreact,javascriptreact,javascript",
    "prefix": "cla",
    "body": "className={styles.${1}$0}"
  },
  "className cn": {
    "scope": "typescriptreact,javascriptreact,javascript",
    "prefix": "cn",
    "body": "className={cn(styles.${1}$0)}"
  }
}

I really love using these snippets. I'm curious - what snippets do you find yourself really using regularly? I'd love to hear about them.

Happy coding!

...



๐Ÿ“Œ The few VS Code snippets that I use regularly


๐Ÿ“ˆ 60.52 Punkte

๐Ÿ“Œ Project Snippets 1.5 - Simple snippets manager with focus on projects.


๐Ÿ“ˆ 36.62 Punkte

๐Ÿ“Œ Boost Your Productivity: How to Create and Use Custom Snippets in VS Code


๐Ÿ“ˆ 26.8 Punkte

๐Ÿ“Œ Over 90% of College Students Today Regularly Use Netflix, But Only 34% Are Actually Paying For Their Own Account


๐Ÿ“ˆ 26.09 Punkte

๐Ÿ“Œ LPT: Use zswap if your device starts swapping and freezes regularly!


๐Ÿ“ˆ 26.09 Punkte

๐Ÿ“Œ Does anyone use ed regularly? What for?


๐Ÿ“ˆ 26.09 Punkte

๐Ÿ“Œ bcal - a tool for devs who use bits, bytes and addresses regularly


๐Ÿ“ˆ 26.09 Punkte

๐Ÿ“Œ Don't use these passwords: These are the 10 logins most regularly found for sale online


๐Ÿ“ˆ 26.09 Punkte

๐Ÿ“Œ How do you remember certain commands and their arcane flags, if you do not use them regularly?


๐Ÿ“ˆ 26.09 Punkte

๐Ÿ“Œ Quickly add boilerplate code snippets with VS Code #Shorts


๐Ÿ“ˆ 26.06 Punkte

๐Ÿ“Œ Share private code using Share code snippets


๐Ÿ“ˆ 26.06 Punkte

๐Ÿ“Œ Custom Code Snippets in VS Code


๐Ÿ“ˆ 26.06 Punkte

๐Ÿ“Œ US Marines seek a few supposedly good men ... who leaked naked pics of a few good women


๐Ÿ“ˆ 24.48 Punkte

๐Ÿ“Œ Review of a few Distros (and a few non Linux OSes!)


๐Ÿ“ˆ 24.48 Punkte

๐Ÿ“Œ Bugtraq: Cross-Site Scripting in Code Snippets WordPress Plugin


๐Ÿ“ˆ 22.19 Punkte

๐Ÿ“Œ WordPress Code Snippets 2.6.1 Cross Site Scripting


๐Ÿ“ˆ 22.19 Punkte

๐Ÿ“Œ Bugtraq: Cross-Site Scripting in Code Snippets WordPress Plugin


๐Ÿ“ˆ 22.19 Punkte

๐Ÿ“Œ WordPress Code Snippets 2.6.1 Cross Site Scripting


๐Ÿ“ˆ 22.19 Punkte

๐Ÿ“Œ Code Snippets < 2.14.0 - CSRF to RCE


๐Ÿ“ˆ 22.19 Punkte

๐Ÿ“Œ WordPress Plugin โ€œCode Snippetsโ€ Vulnerability Risked Over 200K Websites


๐Ÿ“ˆ 22.19 Punkte

๐Ÿ“Œ Frida code snippets for Android


๐Ÿ“ˆ 22.19 Punkte

๐Ÿ“Œ Meet the Bots That Review and Write Snippets of Facebook's Code


๐Ÿ“ˆ 22.19 Punkte

๐Ÿ“Œ Bing Now Provides Exact Snippets of Code for Developers' Queries


๐Ÿ“ˆ 22.19 Punkte

๐Ÿ“Œ Meet the Bots That Review and Write Snippets of Facebook's Code


๐Ÿ“ˆ 22.19 Punkte

๐Ÿ“Œ Woody Ad Snippets Plugin up to 2.2.4 on WordPress class.import.snippet.php Code Execution cross site scripting


๐Ÿ“ˆ 22.19 Punkte

๐Ÿ“Œ Xamarin.Forms Code Snippets | The Xamarin Show


๐Ÿ“ˆ 22.19 Punkte

๐Ÿ“Œ 12 JavaScript Code Snippets That Every Developer Must Know


๐Ÿ“ˆ 22.19 Punkte

๐Ÿ“Œ Snippets & Code repository with collaboration


๐Ÿ“ˆ 22.19 Punkte

๐Ÿ“Œ Malwinx - Just A Normal Flask Web App To Understand Win32Api With Code Snippets And References


๐Ÿ“ˆ 22.19 Punkte











matomo