In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "how to set up your own code snippet in Sublime3". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to set your own code snippet in Sublime3.
Set up your own code snippet in Sublime Text 3
When writing code, I often write the author, creation time, and so on in the comments, which leaves my own mark. Today I will teach you how to build your own comment code block (Snippets).
Sublime Snippets (code snippet)
Sublime text 3 Snippets is an important feature that you need to repeatedly enter the same snippet of text and code.
Snippets can be stored in any package folder, but for simplicity, it is recommended to save it in the Packages/User directory first.
The file format of Snippets is. Sublime-snippet, and usually the structure of Snippet is as follows
Xyzzy source.python My Fancy Snippet
As long as we replace the content in CDATA with our own, we can write the simplest Snippets.
Create your own Snippets
Next, let's write a Snippet using our own code comments as an example.
First, select Tools | Developer | New Snippets in the sublime menu bar. And then enter
Comm source.js
Among them, content is the content of Snippet, tabTrigger is the file form that you can recognize as the effective representation of Snippet,scope when you enter, ${} in content is the content that can be selected by tab key after you have finished typing, ${1:} is selected directly after you type, ${2:} is the content selected by tab once, and so on.
Then save it as comment.sublime-snippet, then type comm in any js file, press the tab keyboard, and your Snippet will appear.
Time input plug-in
Snippet has been generated, but the time is not ready. Next, create your own plug-in and select Tools | Developer | New Plugin in the sublime menu bar. , enter the following
Import sublime, sublime_pluginfrom time import localtime, strftimeclass InsertDatetimeCommand (sublime_plugin.TextCommand): def run (self, edit): sel = self.view.sel (); for s in sel: self.view.replace (edit, s, strftime ("% Y-%m-%d,% H:%M:%S GMT%z", localtime ()
Save as insert_datetime.py, and then add it to Preference | Key Bindings
{"keys": ["super+ctrl+t"], "command": "insert_datetime"}
This means that you can insert time by pressing ⌘ + Control+T. With the Snippet above, you can easily generate your own comments after inserting comments and adding time and description, as follows
/ * * @ author: ManiaU* @ createTime: 2017-03-14, 22:33:00 GMT+0800* @ description: This is a testfragments / so far, I believe you have a better understanding of "how to set your own code snippet in Sublime3". You might as well do it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.