Sublime text 2

Source: Internet
Author: User
Code Editor or text editor. For programmers, like a sword and a warrior, everyone wants to have a treasure sword that can be controlled at will, and every programmer, the same will go to the powerful and flexible editor that best suits you. I believe you and me are the same and will not be an exception.
I have used many editors ~ However, I don't have any special options, until I met sublime text 2! Assuming that "artifacts" are the top comments I can give to a software, I would like to add such a title to it. It is small, green, and fast. It supports windows, Mac, and Linux platforms, 32-bit and 64-bit, syntax highlighting, and Code Completion in various popular programming languages, however, it has many cool features that are not available in other editors, so that its ease of use has reached an unprecedented level ......


About sublime text 2:

Some people have said that there are two kinds of editors in the world, which are easy to use and difficult to use. There are two kinds of editors that are free and expensive. For example, using vim and textmate is a typical example of free and expensive. Unfortunately, sublime text 2, the main character of today, is also an expensive and expensive representative. It is a paid commercial software with a personal license fee of up to 59 USD.


It's just that you don't have to worry about it. Although it is very expensive, the author provides users with unlimited and unlimited trial permissions for free. It will only occasionally remind you that you have purchased the product, and the frequency is also very low. That's all. It's almost no matter whether it is used for free. It is also worth mentioning that users can purchase an authorization and use it on different platforms at the same time, users like me who often need to switch between MAC and win can save a lot of money.
As the sublime text 2 editor has too many features and skills to use, I am not very proficient in it, so I cannot list them one by one, I just want to introduce a few features that I think are more distinctive than NLP, and there is no space here to introduce various editing techniques, shortcut keys, and so on. If you are willing to spend a bit of time, you will find that its capabilities far exceed the points described in this article. Therefore, this article is just a reference. I hope you can share your skills with us.

Syntax highlighting, code prompting completion, code folding, Custom Skin/color scheme, and multiple tabs:

Sublimetext2 supports but is not limited to C, C ++, C #, CSS, D, Erlang, HTML, groovy, Haskell, HTML, Java, JavaScript, latex, lisp, Lua, markdown, syntax highlighting for mainstream programming languages such as MATLAB, ocaml, Perl, PHP, Python, R, Ruby, SQL, TCL, textile and XML. St2 has excellent code self-completion functions (you can manually complete matching symbols such as brackets, braces, and so on; you can manually complete existing words; you can also manually complete function names), which is intelligent; in addition, st2 also has the code snippet (SNIPPET) function, which can save frequently used code snippets and call them whenever necessary. Of course, syntax highlighting, code folding, line number display, Custom Skin, color scheme, and so on are already the standard features of a modern editor, so I will not introduce them here.



Helpful and convenient code prompts


Code map, multiple interface la S, and full-screen anti-disturbing mode:

On the sublime text 2 page, sublime text 2 supports a variety of la S and code maps. It also provides F11 and SHIFT + F11 to enter the full-screen anti-disturbing mode. It is difficult to describe the text.


Code map and multiple tabs


Multiple layout settings, especially when you need to edit multiple files on a large screen or at the same time


Full Screen without disturbing mode, more focused on editing


Fully open user-defined configurations and wonderful and useful editing status recovery functions:

All the configurations of sublime text 2 are controlled by the configuration file, which can be completely defined by the user. Suppose you are willing to make the effort, it can even be changed to a completely different operating experience from the original version. As shown in the figure below, the setting-default menu will open the default software configuration file (this file will record a lot of configuration information such as the font used ), key bindings-default is the default shortcut key configuration file. You can open them to see how some of the original settings are configured, but it is not recommended to change them here! You can change it in the file ending with-user (that is, the meaning of the User-Defined configuration) by drawing a gourd. Suppose there are the same projects on both sides, it is subject to the-User File's surface definition.


In this example, the first line in key bindings-user is {"keys": ["Alt + up"], "command": "swap_line_up "}, that is to say, when you press Alt + direction key, move the selected row up (switch the position with the previous row). If the syntax is correct, after saving the file, you can use the shortcut key immediately.


The sublime text 2 shortcut key also supports dual combinations. For example, by default, the selected text is changed to the upper-case hot key "Ctrl + k, CTRL + u ", it means that when you press Ctrl + k first and then press Ctrl + u to trigger it (only pressing CTRL + k does not work), so as to avoid many hot key conflicts, you can also customize hotkeys in many other ways. I am not going to teach you how to modify various configurations or modify the hotkeys here. I am afraid this will allow you to have a hand-held notebook. Here is a complete set of official documents (BIRDS ), if you are interested, you can take the exam.
In addition, another noteworthy detail of sublimetext, "Edit state recovery", is that when you change a file but do not save it, you exit the software, st2 does not trigger that you want to save it. Because, whether the user exits spontaneously or unexpectedly, the status of your previous edits will be completely restored after the software is started, just like before you quit. I think this detail is very awesome! Because I often try to change some places, but I don't want to save it before I make sure there is no problem. In this case, if some things interrupt me and I need to leave, this feature is very practical, exit directly. If you are bored, open the software next time and continue editing. Of course, with this Recovery feature, we are no longer afraid of system crashes or power outages. It really makes us feel that st2 is particularly secure and reliable!


Powerful multi-line selection and multi-line editing:

During code writing, we often need to edit multiple lines of code or variables at the same time. Sublime text 2 has many useful multi-line operation skills, which can greatly improve the editing speed! I believe that in the future, you may ask yourself, "How did I survive when there was no such editor ?!"
Here are some of the methods for multi-line editing I know:
Select multiple rows with the mouse, and press Ctrl + Shift + L (command + Shift + l) to edit these rows at the same time;
Press Ctrl + d (command + d) again to select the next text and edit it at the same time;
Press Alt + F3 (WIN) or Ctrl + command + g (MAC) to select all the same text for editing at the same time;
Shift + right-click (WIN) or option + left mouse button (MAC) or use the middle mouse button to select vertical lines;
CTRL + left mouse (WIN) or command + left mouse (MAC) can manually select multiple texts to be edited at the same time
There are many similar skills. Please add ......


Shift + right-click


Lightning-like high-speed file switching:

Suppose you open multiple files at the same time, or you often need to edit different files in your project. When the number of files is large, in the past, it was annoying to spend a lot of energy searching. 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, after you press enter, you can instantly switch over! In addition, fuzzy match is supported. You only need to enter a part you remember. For example, I want to find a "www.iplaysoft.com. PHP files, you only need to enter "IPL" or "IPs. C "can be matched. This feature is very good!



In the figure, the Ca matches capabilities. php and classese. php, And you can switch between them at high speed.


I have seen similar functions only in large (bulky) ide such as Eclipse, but for the first time in a small and high-speed editor. To use this function, you can switch between opened files. Assume that you use project management (set a directory as a project ), it can also search for files that have not been opened in the matching project directory. Do you still need to use the mouse to switch between tabs one by one? Do you need to open "my computer" and find the files to be edited in different directories? To use st2, you only need to enter a few characters ~ Just one sentence: unprecedented convenience!


Navigation as you like: High-Speed listing and locating of function/HTML elements, jump to a specified row

Using the high-speed file switching function described above, you can easily open/switch to the document you want to edit, but assuming that the code of this file is very long, what are the best methods to easily jump to the location you want to edit? Sublime text 2 has been ready for you for a long time. Press Ctrl + P (WIN) or SHIFT + command + P (MAC) As mentioned earlier. Please try to enter a @ number first? Well, that's good! This list will help you list all functions in this file now! If fuzzy match is used, input several keywords at a high speed to locate the function immediately !!! This function is especially useful when you need to constantly jump between multiple functions ~ Mom no longer needs to worry about finding a function! When you edit HTML, the items listed here are the ID elements of HTML. I believe the front-end students are frozen.


Press Ctrl + P and enter @, or press Ctrl + R to list all functions in the file.


Enter the @ sign to start with this wonderful effect. Try entering an English Colon: start, and then enter a number. Well, this time you can jump to the specified number of rows; start with #, And you can list/search for text. You can also use shortcuts with higher speed, for example, the high-speed list/jump function is Ctrl + R (command + R under MAC), which is equivalent to entering @ After Ctrl + P @; the jump to the specified row number is Ctrl + g (the Mac is command + G ).
What's even more striking is that you can also use these switchover locating methods together! For example, if I have a file named "hello-iplaysoft.js" with a function named "visit_iplaysoft_com", and I want to edit this function now, I just need to press Ctrl + P, enter "[email protected]" And press enter (fuzzy match, note that there are color characters in front). st2 will immediately open the file and locate it! Is it convenient ?! NOTE These shortcut keys to switch and edit files in one go. You will find the world better ......

Command Panel that combines all functions:

A major feature of sublime text 2 is its powerful Command Panel, which is almost omnipotent! At any time, press Ctrl + Shift + P (WIN) or command + Shift + P (MAC. With this, you can implement many, and many functions. For example, "set Syntax: PhP" can set the current document to PHP syntax highlighting; "Convert case: swap case "is used to convert the selected text into uppercase and lowercase letters;" file: Save all "is used to save all files at a time;" file: Close all "is used to close all files at a time ...... In addition, the list here also supports Fuzzy Matching (this product is really a good thing !). Because there are too many commands and a wide range of functions, I cannot describe them one by one here. If you are interested, you can often call a panel to see what commands are in the list. Learn more, try more, and digest them slowly. I believe it will make you unable to leave it any more.



Powerful Command Panel that can call all functions provided by sublimetext


Package control (do not miss the extension Package Manager)

In addition to its numerous useful functions and features, sublime text 2 can also be installed with various extensions, skins, and color schemes to enhance itself. The package control introduced today can be viewed as an Extension Manager of st2, you can download, install, and delete various plug-ins and skins of sublime text 2 in amazing, easy and convenient ways. Believe me, to better use st2, you must never have it! But st2 does not come with this tool. We need to install it on our own. The method is very easy:
1. Find the data> installed packages folder in the sublimetext2 folder (if not, manually create a folder)
2. Download the package control. sublime-package file here.
3. Put the downloaded file in installed packages.
4. Start sublime text again.
If the package control has been successfully installed, CTRL + Shift + p call the Command Panel and we will find some commands starting with "package control, we often use several install package (installation extension), list packages (list all extensions), remove package (remove extension), and upgrade package (upgrade extension ). However, if you are not sure about the above method, you can press Ctrl + ~ on the keyboard ~ (Press the button on the left of number 1) to bring up the console, copy the following code and press Enter. It will automatically help you create a directory and download the file, the effect is the same as that of 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 package control is installed successfully, a series of commands starting with package name will appear in the Command Panel


In the Command Panel, enter "package control: Install package" to list all the extensions that can be installed (the network must be connected, for example,, 4gl and aaapackagedev are plug-ins. You can download and install them. From this list, we can see that the various extensions of st2 are now very rich! In addition, you can also see the extended list and specific descriptions of the web version here (the data in these two lists should be synchronized. As of February 8, 482 expansion packages have been collected)




Here, I will install the "jsformat" plug-in as an example to introduce how to install and use the plug-in sublimetext. The jsformat function is to typeset some messy JavaScript code to facilitate reading and editing. Use Ctrl + Shift + P to call the Command Panel, enter "package control: Install package" (to install the extension package), and select "jsformat" to install in the plug-in list (to be able to input character filtering ), the installation is completed after the prompt is successful. Open a JS file (preferably a line break or messy alignment), press Ctrl + Shift + P to call the Command Panel, and you will find that there is an additional command called "format: javaScript ",


Use the format: javascript command of the jsformat plug-in


After use, your code instantly becomes neat! You can also use the hotkey "CTRL + ALT + F" of this plug-in to organize it (you can see it on the right of the Command Panel ).


JS Code effects after using jsformat. Note that JS Code is a bunch


Of course, different extensions are used in different ways and in different forms. Therefore, you can simply go to the web version to check some detailed instructions on the use of this plug-in. This cannot be generalized here. In general, installing and using plug-ins is so simple. With various plug-ins, you almost can implement whatever features you want. In addition, st2 also opens the plug-in API. If you have the ability, you can try to develop a plug-in API. You can refer to the API documentation here. Some useful plug-ins will be recommended later in this article.

Change the subject or color scheme:

If you are tired of reading the original version of sublimetext, you can also change your skin. For example, theme-soda is a popular theme-soda topic in idea. It is basically the same as installing the plug-in. You can use package control to enter the list of install packages and find it for installation. You can also find some st2 topics on the internet, download them and put them in the data \ packages folder of the installation folder, and then select to switch the topic. The operation of the color scheme is similar. Let's study it by yourself. We will not introduce it here.



In addition, sublimetext is very powerful, that is, it can native support textmate bundle and color scheme, and can also be used in the packages directory. Textmate has rich bundle and color scheme resources, which can be found on the Internet.


Some recommended plug-ins:

Here are some plug-ins that I think are good about. You are welcome to recommend and supplement them:
Gits: Easy integration with GitHub
SFTP: directly edit files on FTP or SFTP Server
Zencoding: This product is incredibly difficult for front-end students to write HTML files (video demonstration) at a high speed)
Converttoutf8: st2 only supports utf8 encoding, which can display and edit encoded files such as GBK, big5, EUC-KR, EUC-JP, shift_jis, etc.
Clipboard history: clipboard history
WordPress: integrates some WordPress functions. It is especially useful for people like me who often want to write WP templates and plug-ins!
Htmltidy: clear and typeset your HTML code
Phptidy: PHP code for sorting and formatting
Yui Compressor: compresses JS and CSS files

Some Supplements:

Because sublimetext is a green software, user-defined configuration and downloaded plug-ins are all located in the software folder, once you configure it, use a synchronous Network Disk such as Dropbox and Kingsoft fast disk for synchronization (a friend without network can also use a USB flash disk). It is very convenient to execute your own configuration wherever you go! In the future, everyone will work on different computers.
In addition, a lot of friends reflect that there will be garbled characters to open Chinese, in fact, because st2 itself only supports UTF-8 encoding, and we often encounter Chinese files may be GBK or gb2312 encoding, the solution is to install a converttoutf8 or GBK encoding support plug-in to solve the problem perfectly. This is not a big problem.


Related Files:

Official site: Q &
Software: free trial + free trial

Zookeeper Demo: Click to open the link


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.