search
Homephp教程php手册Detailed explanation of Sublime Text 2

Code editor or text editor, for programmers, is like a sword and a warrior. Everyone wants to have an extremely sharp sword that can be controlled at will, and every programmer, too I will pursue the most powerful and flexible editor that suits me. I believe that you, like me, will not be an exception.
I have used a lot of editors, really a lot~ but there was no one that I particularly liked until I met Sublime Text 2! If "artifact" is the highest praise I can give a piece of software, then I am happy to give it such a title. It is small, green and very fast. It supports Win/Mac/Linux across platforms, supports 32 and 64 bits, and supports syntax highlighting, code completion, etc. of various popular programming languages. However, it has many cool features that other editors do not have. Its features make it easier to use than ever...

About Sublime Text 2: Someone once said that there are two types of editors in the world, those that are easy to use and those that are not easy to use; and among the editors that are easy to use, there are two types, free ones and expensive ones. For example, VIM and TextMate are free and expensive examples. Unfortunately, today’s protagonist, Sublime Text 2, is also very expensive. It is a paid commercial software, with a personal license fee of up to $59.

But don’t panic, although it is very expensive, the author is kind enough to provide users with free unlimited and unlimited trial rights, it will only Occasionally reminding you that you have not purchased, and the frequency is very low, nothing more, there is almost no impact if you continue to use it for free. It is also worth mentioning that users can purchase one license to use it on different platforms at the same time. For users like me who often need to switch between Mac and Win, it can indeed save a lot of money.
Because the Sublime Text 2 editor has too many features and usage techniques, and I am not proficient in using it, so I cannot list them all. I can only select a few features that I think are more distinctive to introduce, and There is no space here to introduce various editing techniques, the use of shortcut keys, etc. If you are willing to spend time toying with it, you will find that its capabilities are far beyond the few points introduced in this article, so this article can only be regarded as an introduction. I hope everyone has good skills to share.

Syntax highlighting, code prompt completion, code folding, custom skin/color scheme, multiple note pages: SublimeText2 supports but is not limited to C, C, C#, CSS, D, Erlang, HTML, Groovy, Haskell, HTML, Java, JavaScript, LaTeX, Lisp, Lua, Markdown, Matlab, OCaml, Perl, PHP, Python, Syntax highlighting for mainstream programming languages ​​such as R, Ruby, SQL, TCL, Textile and XML. ST2 has excellent code auto-completion (Automatically complete brackets, braces and other matching symbols; automatically complete words that have already appeared; automatically complete function names), very smart; in addition, ST2 also has a code snippet (Snippet) function, which can save commonly used code snippets , called at any time when needed. Of course, syntax highlighting, code folding, line number display, custom skins, color schemes, etc. are already standard features of a modern editor, so I won’t introduce them here.


Practical and convenient code prompt completion function


##Code map, multiple interface layouts and full-screen do not disturb mode:
Sublime The interface of Text 2 is more distinctive in that it supports multiple layouts and code maps. It also provides F11 and Shift F11 to enter the full-screen do not disturb mode. It is difficult to describe in words. Take a look at the picture below.


##Code map and multi-tab page




##Multiple layout settings, especially convenient for large screens or when multiple files need to be edited at the same time




Full screen do not disturb mode, more focused on editing

Completely open user-defined configuration and magical and practical editing status recovery function:

Various configurations of Sublime Text 2 are configured by File control can be completely customized by the user. If you are willing to fiddle with it, you can even change it to provide a completely different operating experience from the original version. Look at the picture below, the Setting - Default menu will open the default software configuration file (this file will record some configuration information such as what font to use), Key Bindings - Default is the default shortcut key configuration file, you can open them to see See how some of the original settings are configured, but it is not recommended to modify directly here! You can do this in - User The file at the end (that is, the meaning of user-defined configuration) is modified as usual. If there are the same items on both sides, it will be based on the one defined in the -User file.


In this example, I am in the first line in Key Bindings - User: { "keys": ["alt up"], "command": "swap_line_up" }, which means that when pressing the Alt direction key up, the currently selected line will be moved up (exchange positions with the previous line). If The syntax is perfect. You can use this shortcut key immediately after saving the file.


Sublime Text 2's shortcut keys also support dual combinations. For example, by default, the hotkey to change the selected text to uppercase is "Ctrl K, Ctrl U". This means that when you first press Ctrl K and then quickly press Ctrl U to trigger (just pressing Ctrl K has no effect), this can avoid many hotkey conflicts and can also customize hotkeys more flexibly and with more options. . However, I am not going to teach you how to modify various configurations or modify hotkeys here. I am afraid that a manual can be published. Here is a relatively complete set of official documents (Niaoyu). Friends who are interested can refer to it.
In addition, there is another detail worth mentioning in SublimeText - "Editing Status Recovery", that is, when you modify a file but do not save it, and then exit the software, ST2 will not annoyingly prompt you if you want to Saved, because whether the user exits spontaneously or crashes unexpectedly, the next time you start the software, your previous editing status will be completely restored, just like before you exited. I think this detail is very, very good! Because I often try to modify some places, but I don’t want to save it before making sure there are no problems. At this time, if something interrupts me and I need to leave, this feature is very useful. Just exit directly. Don’t bother. Next Just come back and open the software to continue editing. Of course, with this recovery feature, you no longer have to worry about system crashes or power outages. It really makes people feel that ST2 is particularly safe and reliable, and it's absolutely perfect!

Powerful multi-line selection and multi-line editing:

In the process of writing code, we often need Edit multiple lines of code or multiple variables at the same time. There are very practical multi-line operation skills in Sublime Text 2. Flexible use can greatly improve the editing speed! I believe you may ask yourself in the future: "How did I survive when there was no editor like this?!"
Here are some multi-line editing methods that I know:
Select multiple lines with the mouse lines, press Ctrl Shift L (Command Shift L) to edit these lines at the same time;
Select the text with the mouse, press CTRL D (Command D) repeatedly to continue downward and select the next same text for simultaneous editing;
Select text with the mouse and press Alt F3 (Win) or Ctrl Command G (Mac) to select all the same text at once for editing;
Shift right mouse button (Win) or Option left mouse button (Mac) ) or use the middle mouse button to select vertical multiple lines with the mouse;
Ctrl left mouse button (Win) or Command left mouse button (Mac) can manually select multiple text to be edited at the same time
Similar techniques There are many more, please add more...


## Shift right-click to easily edit multiple lines , prefixed to variables in batches

Thunder-fast file switching:

If you open multiple files at the same time, or you often need to edit different files in your project When there were a large number of files, it used to take a lot of effort to find them, which was very annoying. Now, in Sublime Text 2, you only need to press Ctrl P (Win) or Shift Command P (Mac) to bring up the file switching panel. Then you only need to enter the file name and press Enter to switch to it instantly! And it supports fuzzy matching. You only need to enter part of the file you remember. For example, if I want to find a "www.iplaysoft.com.php" file to edit, then you only need to enter "ipl" or "ips.c" "Such characters can be matched. This feature is very, very great!


##ca in the picture matches capabilities. php and classese.php, you can quickly switch to

similar functions by selecting them. I only use them in large-scale applications such as Eclipse I have only seen it in (bulky) IDEs, but this is the first time I have encountered it in a small and fast editor. Using this function, in addition to switching between open files, if you use project management (set a folder as a project), it can also know how to search for unopened files in the matching project folder. . Now you still need to use the mouse to click on the tabs one by one to switch? Do you still have to open "My Computer" and slowly search through different folders to find the files that need to be edited? With ST2, you only need to enter a few characters ~ only one sentence: unprecedented convenience!

Jump as you like: quickly list and position functions/HTML elements, jump to the specified line
Using the fast file switching function introduced above, you can easily open/switch to the document you want to edit. However, if the code of this file is very long, what is a good way to easily jump to the place you want to edit? Woolen cloth? Sublime Text 2 has already thought about it for you. You can also press Ctrl P (Win) or Shift Command P (Mac) as mentioned above. This time, try entering an @ sign first? Well, good job! This list will immediately help you list all the Functions in this file! Also use fuzzy matching, quickly enter a few keywords, and you can immediately locate the Function! ! ! This function is especially useful when you need to constantly jump between multiple functions. Mom no longer has to worry about me finding functions! When you are editing HTML, what this guy lists for you is the various ID elements of HTML. I believe all front-end students will be stunned.



##Ctrl P followed by the @ sign or just press Ctrl R. List all the functions in the file



##Enter the @ number to start having such a magical effect, then Try entering an English colon: Start, then enter a number, well, this time you can jump to the specified line number; enter a # sign to start, you can list/search text; and you can also use faster Shortcut keys, for example, the quick list/jump function is Ctrl R (Command R on Mac), which is completely equivalent to entering @ after Ctrl P; jumping to the specified line number is Ctrl G (Command G on Mac).

What’s even more amazing is that you can use these switching positioning methods together! For example, I have a file named "hello-iplaysoft.js", and there is a function in it called "visit_iplaysoft_com". If I want to edit this function now, I only need to press Ctrl P and enter "heip@vi" Press Enter (fuzzy matching, pay attention to the colored characters in front), ST2 immediately opened the file for me and positioned it! Convenient enough, right? ! Memorize these shortcut keys, and you can switch and edit files in one go. You will find that the world is a better place, dear...



All-in-one command panel:

One of the major features of Sublime Text 2 is a very powerful command panel, which Almost anything is possible! At any time, press Ctrl Shift P (Win) or Command Shift P (Mac) to bring it up. Using it, you can achieve many, many, many, many functions, such as "Set Syntax:PHP" to set the current document to PHP syntax highlighting; "Convert Case: Swap Case" to reverse the case of the selected text; " File: Save All" can save all files at once; "File: Close All" can close all files at once, etc... Moreover, the list here also supports fuzzy matching (this thing is really a good thing!). Because there are so many commands here and they cover a wide range of functions, I really can’t introduce them one by one here. If you are interested, you can always adjust the panel to see what commands are in the list, and learn more about and try them. , and then digest it slowly, I believe it will make you unable to live without it again.


Powerful command panel, where you can call all the functions provided by SublimeText


##Package Control (an expansion pack manager you must not miss)
In addition to its numerous useful functions and features, Sublime Text 2 can also be installed and used with various extensions/skins/color schemes etc. to enhance itself. The Package Control introduced now can be regarded as an ST2 extension manager. Using it, you can download, install, and delete various plug-ins, skins, etc. of Sublime Text 2 in a very magical, very simple and convenient way. Trust me , if you want to use ST2 better, you must not live without it! However, ST2 itself does not come with this tool. We need to install it ourselves. The method is very simple:
1. Find the Data > Installed Packages folder in the SublimeText2 directory (if not, please create it manually)
2 , Download the Package Control.sublime-package file here
3. Put the downloaded file into Installed Packages
4. Restart Sublime Text
If Package Control has been installed successfully, then Ctrl Shift P Call the command panel, and we will find some commands starting with "Package Control:". The ones we commonly use are several Install Packages (install extensions), List Packages (list all extensions), and Remove Package (remove extensions) , Upgrade Package (upgrade extension). But if you really can’t figure it out according to the above method, you can try pressing Ctrl ~ (the key to the left of the number 1) on the keyboard to bring up the console, then copy the following code into it and press Enter. It will automatically create a new folder for you and download it. file, the final effect is the same as the above method:

import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'




After successfully installing Package Control, a series of commands starting with its name will appear in the command panel


Enter "Package Control: Install Package" in the command panel and all the extensions that can be installed will be listed (need to be connected to the network, as shown below). As you can see from the list, 4GL and AAAPackageDev are the names of the plug-ins. Select them to download and install them. As you can see from this list, the various extensions of ST2 are already very rich! Additionally, you can see the Web here version of the expansion list and detailed description (the data of these two lists should be synchronized. As of the deadline of 2012-7-8, 482 expansion packs have been collected here)




#Here I will take the installation of the "JsFormat" plug-in as an example to briefly introduce how to install and use the plug-in in SublimeText. The function of JsFormat is to rearrange some messy JavaScript codes to facilitate better reading and editing. Use Ctrl Shift P to call the command panel, enter "Package Control: Install Package" (install the expansion package), select to install "JsFormat" in the plug-in list (you can enter characters to filter), and the installation will be completed after the success prompt. Just open a js file (preferably one with line breaks and messy alignment) and press Ctrl Shift P Call the command panel, you will find that there is an additional command called "Format: Javascript", as shown in the figure:


##

Use the Format of JSFormat plug-in: Javascript command


After using, your code It instantly became tidy! You can also use the hotkey "CTRL ALT F" of this plug-in to organize (can be seen on the right side of the command panel).


The JS code effect after using JSFormat. Note that the JS code in the above picture is a bunch of Of course, different extensions use different methods and expressions. This is You can only go to the web version to check some specific instructions for using this plug-in, and generalizations cannot be made here. But in general, installing and using plugins is that simple. Through various plug-ins, you can achieve almost any function you want. Moreover, ST2 also opens the plug-in API. If you have the ability, you can also try to develop one. You can refer to the API documentation here. Some practical plug-ins will be recommended later in this article.


Change the theme or color scheme:



If you are tired of the original version of SublimeText You can also do some skin resurfacing. For example, the picture below shows a popular theme Theme - Soda. It is basically the same as installing a plug-in. Use Package Control to enter the Install Package list to find it and install it. You can also find some ST2 themes on the Internet, download them and put them in the Data\Packages folder of the installation directory, and then choose to switch themes. The operation of the color scheme is also similar. You can study it yourself. I won’t introduce it here.





in addition, Another great thing about SublimeText is that it natively supports TextMate's Bundle and color scheme, and it can also be used in the Packages folder. TextMate has rich bundles and color scheme resources, and you can find many of them online.



## Recommended plug-ins:

Here are some plug-ins that I think are good. Everyone is welcome to recommend and add:
Gits: You can easily integrate GitHub
SFTP: Directly edit files on the FTP or SFTP server

ZenCoding: This product is suitable for This is amazing for front-end students, you can write HTML files super quickly (video demonstration)

ConvertToUTF8: ST2 only supports utf8 encoding, this plug-in can display and edit GBK, BIG5, EUC-KR, EUC-JP, Shift_JIS and other encodings FileClipboard History: Clipboard HistoryWordPress: Integrate some WordPress functions, especially useful for people like me who often write WP templates and plug-ins! HtmlTidy: Clean and format your HTML code PHPTidy: Organize and format your PHP code YUI Compressor: Compress JS and CSS files







Some additions:



Because SublimeText is green software, the user’s customized configuration, downloaded plug-ins, etc. are located in the software directory, so once you configure After that, use a synchronization network disk such as Dropbox or Kingsoft Express to synchronize (friends without Internet access can also use a USB flash drive). You can run it with your own configuration wherever you go, which is very convenient! I believe everyone will be able to work on different computers very smoothly in the future.
In addition, many friends reported that there will be garbled characters when opening Chinese. In fact, this is because ST2 itself only supports UTF-8 encoding, and the Chinese files we often encounter may be GBK or GB2312 encoding. The solution is to install a ConvertToUTF8 or The GBK Encoding Support plug-in can perfectly solve this problem. This is not a big problem.

This article explains in detail the relevant content of Sublime Text 2. For more related content, please pay attention to the php Chinese website. Related recommendations:
How to get CSS property values ​​through JS


How to determine the collision method through JS

How to use CSS to achieve the circle effect (CSS Sprites)

The above is the detailed content of Detailed explanation of Sublime Text 2. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
php如何使用PHP的SNMP扩展?php如何使用PHP的SNMP扩展?Jun 02, 2023 am 10:22 AM

PHP的SNMP扩展是一种使PHP能够通过SNMP协议与网络设备进行通信的扩展程序。使用该扩展可以方便地获取和修改网络设备的配置信息,例如路由器、交换机等设备的CPU、内存、网络接口等信息,也可以进行诸如开关设备端口等控制操作。本文将介绍SNMP协议的基础知识、PHP的SNMP扩展的安装方法以及如何在PHP中使用SNMP扩展进行网络设备的监控和控制。一、SN

如何使用极光推送扩展,在PHP应用中实现批量消息推送功能如何使用极光推送扩展,在PHP应用中实现批量消息推送功能Jul 25, 2023 pm 08:07 PM

如何使用极光推送扩展,在PHP应用中实现批量消息推送功能在移动应用的开发中,消息推送是一项非常重要的功能。极光推送是一种常用的消息推送服务,提供了丰富的功能和接口。本文将介绍如何使用极光推送扩展在PHP应用中实现批量消息推送功能。第一步:注册极光推送账号并获取API密钥首先,我们需要在极光推送官网(https://www.jiguang.cn/push)注册

php如何使用PHP的ZipArchive扩展?php如何使用PHP的ZipArchive扩展?Jun 02, 2023 am 08:13 AM

PHP是一种流行的服务器端语言,可以用来开发Web应用程序和处理文件。PHP的ZipArchive扩展是一个强大的工具,可以在PHP中操作zip文件。在这篇文章中,我们将介绍如何使用PHP的ZipArchive扩展来创建、读取和修改zip文件。一、安装ZipArchive扩展在使用ZipArchive扩展之前,需要确保已经安装了这个扩展。安装方法如下:1.安

php如何使用PHP的Phar扩展?php如何使用PHP的Phar扩展?May 31, 2023 pm 11:31 PM

随着PHP的发展和应用场景的不断扩大,Phar扩展已经成为PHP编程中的重要一环。Phar是PHPArchive的缩写,它可以将多个PHP文件和资源打包成单个文件,方便进行分发和管理。本文将介绍如何使用PHP的Phar扩展来进行打包和管理。安装Phar扩展首先,我们需要检查PHP是否已经安装Phar扩展。在Linux下,通过终端输入以下命令:php-m

php如何使用PHP的POSIX扩展?php如何使用PHP的POSIX扩展?Jun 03, 2023 am 08:01 AM

PHP的POSIX扩展是一组允许PHP与POSIX兼容操作系统进行交互的函数和常量。POSIX(PortableOperatingSystemInterface)是一组操作系统接口标准,旨在允许软件开发人员编写可在各种UNIX或UNIX类操作系统上运行的应用程序。本文将介绍如何使用PHP的POSIX扩展,包括安装和使用。一、安装PHP的POSIX扩展在

PHP和WebDriver扩展:如何模拟用户点击和输入操作PHP和WebDriver扩展:如何模拟用户点击和输入操作Jul 07, 2023 pm 05:10 PM

PHP和WebDriver扩展:如何模拟用户点击和输入操作近年来,随着Web应用程序的快速发展,自动化测试变得越来越重要。在自动化测试中,模拟用户操作是一个关键的环节,它可以使我们更准确地测试和验证我们的应用程序。在PHP开发中,我们通常使用SeleniumWebDriver来实现自动化测试。SeleniumWebDriver是一种强大的工具,它可以模拟

教程:使用百度云推送(Baidu Push)扩展在PHP应用中实现消息推送功能教程:使用百度云推送(Baidu Push)扩展在PHP应用中实现消息推送功能Jul 26, 2023 am 09:25 AM

教程:使用百度云推送(BaiduPush)扩展在PHP应用中实现消息推送功能引言:随着移动应用的迅猛发展,消息推送功能在应用程序中变得越来越重要。为了实现即时通知和消息推送功能,百度提供了一种强大的云推送服务,即百度云推送(BaiduPush)。在本教程中,我们将学习如何使用百度云推送扩展(PHPSDK)在PHP应用中实现消息推送功能。我们将使用百度云

Vue如何实现组件的复用和扩展?Vue如何实现组件的复用和扩展?Jun 27, 2023 am 10:22 AM

随着前端技术的不断发展,Vue已经成为了前端开发中的热门框架之一。在Vue中,组件是其中的核心概念之一,它可以将页面分解为更小,更易管理的部分,从而提高开发效率和代码复用性。本文将重点介绍Vue如何实现组件的复用和扩展。一、Vue组件复用mixinsmixins是Vue中的一种共享组件选项的方式。Mixins允许将多个组件的组件选项合并成一个对象,从而最大

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.