Home  >  Article  >  Development Tools  >  If you configure a small program file in Atom, let the code be highlighted!

If you configure a small program file in Atom, let the code be highlighted!

青灯夜游
青灯夜游forward
2021-06-10 11:07:393471browse

This article will introduce to you AtomHow to configure code highlighting for WeChat applet files. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

If you configure a small program file in Atom, let the code be highlighted!

The file extensions related to the mini program are .wxml, .wxss, .wxs, However, the Atom editor does not automatically recognize these types of files by default. When you open these files, you can only see anti-human black and white code.

An elegant solution is to modify the configuration of Atom so that Atom treats .wxml as .html and .wxss as .css, treat .wxs as .js. In this way, you will see colored codes when opening these types of files. [Related recommendations: "atom tutorial"]

Operation steps

##1. Open config.cson Configuration file

Press the shortcut keys

Command Shift P to invoke the command panel, enter Application: Open Your Config , click Enter key, the file config.cson

If you configure a small program file in Atom, let the code be highlighted!

will open. 2. Modifyconfig.cson Configuration file

Add

customFileTypes:
  'text.html.basic': [
    'wxml'
  ]
  'source.css': [
    'wxss'
  ]
  'source.js': [
    'wxs'
  ]
below core

The approximate structure of the file

"*":
  core:
    customFileTypes:
      'text.html.basic': [
        'wxml'
      ]
      'source.css': [
        'wxss'
      ]
      'source.js': [
        'wxs'
      ]

This There may be many other attributes in the file, because some plug-ins will automatically add configurations to this file

Configuration completed! Reopen the files with the

.wxml, .wxss, wxs suffix, and you will see the colored codes.

Principle

In fact, Atom does not recognize the

wxml file as a html file, but uses and ## Use the same syntax rules as #html files to highlight code in wxml files. text.html.basic, source.css, source.js are the corresponding grammar rule names. These names can be found in language-xxx Such Atom built-in or found in third-party Packages. For more programming-related knowledge, please visit:

Introduction to Programming

! !

The above is the detailed content of If you configure a small program file in Atom, let the code be highlighted!. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:juejin.cn. If there is any infringement, please contact admin@php.cn delete