If you’re someone who uses Notepad++ for writing and editing CSS code. And also you’re using Tailwind CSS in your project. Then you must be finding it difficult and cumbersome to memorize and remember all Tailwind CSS classes. I have a solution to this,
Notepad++ uses language directive XML files to facilitate code auto-completion. I have used this existing feature to extend CSS auto-completion to include all present Tailwind CSS classes.
You can download this file to your computer. Then replace this file with CSS.xml file at this location [C:/Program Files/Notepad++/autoCompletion/css.xml] on your computer. Next Restart your notepad++ and you will be able to type and get hints for predefined Tailwind CSS classes.
See below image for reference
Continue Reading if you’re interested in how this CSS.XML File is generated and it’s purpose in Auto code completion feature of Notepad++
Process: How CSS.xml File is Implemented
You may find this helpful if you’re planning to build a notepad++ plugin or trying to add new functionalities to Notepad++.
Notepad++ doesnβt support Auto-completion for Tailwind CSS classes, a popular open-source library for styling html with minimum efforts. It has thousands of ready available classes that automate CSS styling without having to declare much CSS yourself in a web project.
Note: If Auto-completion is not Active in your Notepad++. To activate Auto-code-completion in your Notepad++ see below
- To activate setting go to Settings Tab -> Click on Preferences, you will see below window.
- Click [ β ] Enable auto-completion on each input and close the window.
Step 1
I needed all the available Tailwind CSS Classes in text to be able to create their individual XML Syntax which then I could add to the Code directives file of Notepad++ Program files.
I found a code snippet in a Github discussion with a ready array of all Tailwind CSS classes. (Link – π https://github.com/tailwindlabs/tailwindcss/discussions/10379 )
Step 2
I created a short JavaScript that used the array of Tailwind CSS class-names. The script code created an array of Strings with array.map() function which converted class-names to an XML Line which is compatible with Notepad++ Syntax for Auto-completion feature directives files. And then printed these XML syntax Strings on window. To later copy – paste to css.xml directive file in Notepad++ Program files.
You can visit this file here which generates the XML (π https://ajitsing.in/notepad%2b%2b/tailwindcss/load-tailwind-css-classes.html )
Here’s the javascript function (part of complete code in above file) that prints the XML Syntax by using the Tailwind CSS classes Array (Github) mentioned above.
Step 3
Auto-completion feature directives files – These are individual files for each language stored at (C:/Program Files/Notepad++/autoCompletion/) Directory. This directory location may differ in your computer.
I copy/pasted these XML tags to (C:Program FilesNotepad++autoCompletioncss.xml) file. While copy/pasting codes to css.xml file Notepad++ may ask you to open Notepad++ with Administrator permission to Save this file.
After I saved the file and Restarted Notepad++, Auto code-completion of Tailwind CSS classes started working in my Notepad++. π
As You can see in the below screenshot.
More About VSCode Plugin:
VSCode has an available plugin that enables Auto-completion Tailwind CSS Classes only by installing the plugin. As shown below.
Features of Tailwind CSS VSCode Plugin
- As user is typing code for example ‘flex’, VS Code’s auto-completion feature (available as plugin) suggests all relevant Tailwind CSS Classes, as you can see in the image.
- Auto-Code Completion Example in Visual Studio Code
- (Screenshot from – https://www.youtube.com/watch?v=pfaSUYaSgRo)
Features of Tailwind CSS VSCode Plugin
- User have hovered on CSS code ‘top-0’ and VS Code has highlighted the actual CSS of that Tailwind CSS Class, as you can see in the image above
- Hover to Preview Code Example in Visual Studio Code
- (Screenshot from – https://www.youtube.com/watch?v=pfaSUYaSgRo)
by ajithimself@yahoo.com
Share
Get In Touch for Free Consultation!
Send Whatsapp Message to
+91 8793326974
Vishal Nagar, Pimple Nilakh
411027
Pune.
Near Wakad.