Sublime Text 2 Introduction

Source: Internet
Author: User


Code Editor or text editor, for the program ape, like a sword and warrior, who would like to have a can control and Ruili incomparable sword, and every program ape, the same will go to pursue the most suitable for their powerful, flexible editor, I believe you and I, no exception.
I have used a lot of editors, really a lot ~ but there is no one that makes me special favorite, until I met the Sublime Text 2! Suppose that "artifact" is the highest rating I can give a software, then I would be happy to seal it with such a title. It is small green and very fast, cross-platform support Win/mac/linux, support 32 and 64-bit, support a variety of popular programming language syntax highlighting, code complement the same, but it has a lot of other editors do not have cool features, so that its easy to use to reach an unprecedented degree ...





About Sublime Text 2:

It has been said in the past that there are two kinds of editors in the world, which are easy to use and not useful, and in the good editor, there are two kinds, free and death expensive. VIM and TextMate, for example, are examples of free and dead expensive. Unfortunately, today's protagonist Sublime Text 2 is also a dead expensive representative, it is a fee for commercial software, personal licensing fees up to 59 U.S. knives.






Just do not panic, although it is very expensive, but the author is very kind to give users free unlimited indefinite trial rights , It will only occasionally remind you that Wood has a purchase, and the frequency is very low, only that, has been free to use it almost no matter what effect. It is also worth mentioning that the user to purchase an authorization can be used on different platforms at the same time, for like me often need to switch between MAC and Win the use of the user can really save a sum of money.
due to the Sublime Text 2 editor features and the use of too much skill, I have not been used to master, so I can not enumerate the show, just select a few I think the characteristics of more features to introduce, and there is no space to introduce a variety of editing techniques, shortcuts use the like. Assuming that you are willing to take the time to toss, you will find that its ability is far more than the points introduced in this article, so this article can only be regarded as a start, I hope we have good skills to share.



Syntax highlighting, code hinting completion, code folding, customizing skin/color schemes, multi-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, Syntax highlighting for mainstream programming languages such as Matlab, OCaml, Perl, PHP, Python, R, Ruby, SQL, TCL, Textile and XML. ST2 has a good code of its own initiative to complete the function (self-closing brackets, braces, such as pairing symbols, their own initiative to fill the words have appeared, their own initiative to complete the function name), very smart; In addition, ST2 also has the function of code Snippets (Snippet) to save frequently used code fragments. Call whenever you need to. Of course, syntax highlighting, code folding, line number display, their own definition of skin, color scheme, etc. these are already a modern editor should have standard features, so there is not much to do introduction.









Useful code hints for full functionality






Code maps, multiple interface layouts, and full-screen intrusion-free mode:

Sublime text 2 is featured on the interface is supported by a variety of layout and code map, but also provides F11 and shift+f11 into the full-screen intrusion-free mode, text difficult to describe the narrative, see it.






Code maps and multi-tabbed pages






Multiple layout settings, especially handy when editing multiple files on a large screen or at the same time






Full screen intrusion-free mode, more focused on editing






Fully open user-defined configuration with wonderfully useful edit state recovery features:

The various configurations of the Sublime Text 2 are controlled by the configuration file, which can be completely defined by the user, assuming you are willing to toss it, or even be able to change it to an entirely different operating experience from the original. Looking at the diagram below, the Setting-default menu will open the default software configuration file (this file will record some very, very many configuration information such as what font to use), key Bindings-default is the default shortcut profile, You can open them to see how some of the original settings are configured, but it is very not recommended to change here directly ! You can do this in the-user end of the file (that is, users define the meaning of the configuration) in the same way to change the same, assuming that the same items on both sides, it will be in the-user file in the definition of the surface prevail.






In this example, I'm in the first line of Key Bindings-user:{"Keys": ["Alt+up"], "command": "Swap_line_up"}, meaning to move the currently selected line up when you press ALT + The arrow key (with the previous line Exchange position), assuming that the syntax of God horse is not a problem, save this file immediately after the use of this shortcut key.




Sublime text 2 shortcut keys also support dual combination, for example, by default, the selected text to uppercase hotkey is "ctrl+k, ctrl+u", meaning when you first press ctrl+k and then quickly press Ctrl+u to trigger (just press ctrl+k is not useful) , which avoids very many hotkey conflicts, and can be more flexible and many other options to define the hotkeys themselves. Just here is not going to teach you how to change the various configuration or change the hotkey, I am afraid it can be a manual, here is a more complete set of official documents (birds of the bird), interested friends can go to the test.
In addition, sublimetext another noteworthy detail-"Edit state Recovery", that is, when you change a file, but not save, then quit the software, ST2 is not very annoying to remind you to do not save, because whether the user spontaneous exit or unexpectedly crashes the exit, the next time after the software launch, Your previous edit status will be fully restored, just like you did before you quit. I feel very, very good about this detail! Because I often try to change some of the places, but in order to ensure that there is no problem before you do not want to save, when it is assumed that some things interrupt themselves, need to leave, this feature is very useful, direct exit can, do not bother, next time back to open the software to continue editing. Of course, with this recovery feature is no longer afraid of the system crashes, power off, it is really let people feel ST2 particularly special safe and reliable, and duly!






Powerful multi-line selection and multi-line editing:

In the process of writing code, we often need to edit multiple lines of code or multiple variables at the same time. In Sublime Text 2 has a very useful multi-line operation skills, flexible use can greatly improve the speed of editing yo! I believe that you may ask yourself this question: "How did I ever come to life when there was no such a way of editing?" ”
Here are some of the multi-line editing methods I've learned:
The mouse selects multiple lines, press Ctrl+shift+l (command+shift+l) can edit these lines at the same time;
Mouse selected text, repeated press ctrl+d (COMMAND+D) can continue to the same time to select the next same text to edit at the same time;
Mouse selected text, press ALT+F3 (Win) or ctrl+command+g (MAC) can select all the same text at once to edit the same time;
shift+ right mouse button (Win) or option+ left mouse button (MAC) or using the middle mouse button to use the mouse to vertical multi-line selection;
Ctrl + mouse button (Win) or command+ left mouse button (MAC) to manually select multiple text to edit at the same time
There are a lot of similar techniques, please add ...






shift+ the right mouse button to easily implement multi-line editing, batch to prefix the variable






Lightning-Fast File switching:

Let's say you open multiple files at the same time, or you often have to edit different files in your project, and when the number of files is large, it often takes a lot of effort to find them in the past, which is very annoying. Now, Sublime Text 2 only need to press Ctrl+p (Win) or shift+command+p (MAC) can bring up the file switcher, and then you just need to enter the name of the file, enter after you can instantly switch the past! And it supports fuzzy matching, just need to enter the part you remember, such as I want to find a "www.iplaysoft.com.php" file to edit, then you just need to enter "IPL" or "IPS.C" character can match out, this feature is very very good!









The CA pabilities.php and CLassese.php are matched in the figure, and the selection can be switched at high speed




Similar functionality, I've only seen it in a large (bulky) IDE like Eclipse, but in a small, high-speed editor, I was first encountered. With this feature, you can switch between open files, assuming that you are using Project management (setting up a directory as a project), and that you can search for files that have not been opened in a matching project directory. Now you need to use the mouse to go to a point tab to switch? Do you want to open "My Computer" slowly in the various directories to find the files that need to be edited? With ST2, you just need to enter a few characters to be able to-just one sentence: unprecedented convenience!






Arbitrary jump: High-speed listing and positioning function/html elements, jump to the specified line

With the high-speed file switching feature described above, it is very easy to open/switch to the document you want to edit, but suppose the code for this file is very long and very lengthy, and what is the best way to easily jump to where you want to edit it? Sublime Text 2 long ago to help you think about, the same is to press the previous ctrl+p (Win) or shift+command+p (MAC), this time try to enter an @ number to see? Yes, good! This list immediately lists all the Function in this file! The same use fuzzy matching, high-speed input a few keyword, immediately can locate the function to go!!! This feature is especially useful when you have to jump between multiple functions ~ Mom no longer have to worry about me finding the function to find the egg hurts! When you edit the HTML, this goods to you list is the HTML of the various ID elements, I believe that the front-end of the students are chicken frozen bar.






You can list all the function in this file by entering the @ number after ctrl+p or by pressing CTRL+R directly






Enter @ To start with this amazing effect, then try typing a colon: start it, then enter a number, well, this time you can jump to the specified number of rows; Enter a # number to start, to list/search for text, and you can also use higher speed shortcuts, such as high-speed list/jump function is Ctrl +r (Mac is command+r), it is completely equal to ctrl+p after input @; Jump to the specified line number is ctrl+g (Mac is command+g).
And even more amazing is that these switching positioning methods you can also cooperate with the use! For example, I have a file called "Hello-iplaysoft.js", in which there is a function called "visit_iplaysoft_com", I now want to edit this function, then I just need to press ctrl+p, and then enter "[Email Protected] "carriage return (fuzzy match, note the character preceded by color), ST2 immediately give me to open this file and position it in! Is it convenient enough?! By memorizing these shortcuts, you'll be able to switch and edit files very one go, and you'll find the world a better place to be!



A command panel that combines all functions:

One of the features of Sublime Text 2 is that it has a pretty powerful command panel that almost omnipotent! Whenever you press Ctrl+shift+p (Win) or command+shift+p (MAC), you can pull it out. With it, you can achieve very many very many very many very many very versatile, such as "set syntax:php" can set the current document to the PHP syntax highlighting; "Convert Case:swap case" to reverse the selected text in uppercase and lowercase; "File: Save All "can save all files at once," File:close all "once close all files, etc... Also, the list here supports fuzzy matching (this goods is really a good thing!). )。 Because this command is too much, the scope of coverage is very wide, I really can not be introduced here, we assume that there is interest, can often adjust a panel to see what the list of what commands, a lot to understand, try, and then slowly digest, I believe it will let you can not leave it.









Powerful command panel, able to invoke all the functions provided by Sublimetext here






Package control (an extension pack manager that must never be missed)

Sublime Text 2, in addition to its own countless useful features and features, it can also be installed using a variety of extensions/skins/color schemes, etc. to enhance themselves. Now introduced the package control can be seen as a ST2 extension manager, using it, you can use a wonderful, easy and convenient way to download, install, delete Sublime Text 2 of various plugins, skins, etc., believe me, want to better use ST2 Absolutely not without it! Just ST2 itself does not bring this tool, we need to install it ourselves, the method is very easy:
1. Find the folder of Data > Installed Packages in SublimeText2 folder (if not, please create it manually)
2. Download the package Control.sublime-package file here
3. Put the downloaded file in installed Packages inside
4, another start Sublime Text can be
Assuming that the package control has been successfully installed, then ctrl+shift+p invokes the command panel and we will find some commands that begin with the "package Control:", which we often use to install a few (installation extensions), List Packages (all extensions listed), remove package (remove extension), Upgrade package (upgrade extension). But suppose you follow the above method does not work, can try to press the keyboard ctrl+~ (number 1 left button) to bring up the console, and then copy the following code into and enter, it will help you to create a new directory and download the file, and the above method finally effect is the same:




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 the package Control is successfully installed, a series of commands starting with its name appear in the command panel






Entering "package Control:install" in the command panel will list all the extensions that can be installed (must connect to the network, for example), from the list can see, 4GL, Aaapackagedev Those is the name of the plugin, Select them to be able to download and install. As you can see from this list, the various extensions of ST2 are now plentiful! In addition, you will be able to see the web version of the extensions list and specific instructions (the data for both lists should be synchronized.) By the deadline of 2012-7-8, 482 expansion packs have been collected here.












I am here to install "Jsformat" plug-in as an example, the introduction of sublimetext inside how to install and use the plugin bar. Jsformat's function is to be able to layout some messy JavaScript code again to make it easier to read and edit. Use Ctrl+shift+p to invoke the command panel, enter "Package Control:install" (Install expansion pack), select Install "Jsformat" in the list of plugins (can input character filter), after the prompt has been successfully installed. Just open a JS file (preferably a newline, a particularly messy kind of), press Ctrl+shift+p to invoke the command panel, you will find that there is an extra command called "Format:javascript",






Format:javascript command using the Jsformat plugin






After use, your code instantly becomes neat and tidy! You can also use the hotkey "ctrl+alt+f" of this plugin to organize (see the command panel to the right).






Using the Jsformat after the JS code effect, note that the JS code is a bunch of






Of course, different extensions, the use of the method and the form of expression are not the same, this can only go to the web version of the plugin to check some of the detailed instructions for use, here is not generalize. Just in general, installing and using plugins is so simple. With a variety of plugins, you are almost able to achieve whatever functionality you want. And ST2 also open the plugin API, assuming you have the ability, you can also try to develop a, can refer to the API document here. Some useful plugins are recommended later in this article.



To change a theme or color scheme:

Suppose you are tired of Sublimetext's original skin, you can also toss a change of skin. Pedagogical gardening For example to be a popular theme Theme-soda, and install plug-ins basically the same, use the package Control into the install package list inside to find it to install it. You can also find some ST2 themes on the web, download them back to the Data\packages folder in the installation folder, and choose to switch themes. The operation of the color scheme is similar, we have to study it, there is not much to do introduction.









In addition, Sublimetext also has a very good point, is that it can natively support the TextMate Bundle and color scheme, the same is placed in the Packages directory can be used. TextMate bundles and color scheme resources are more abundant, online can find a lot.






Recommended part of the plugin:

Here to add some I feel good plug-in bar, welcome you to recommend and add:
Gits: Easy to integrate with GitHub
SFTP: Directly edit files on FTP or SFTP server
Zencoding: The goods for the front-end of the students, can be very high-speed writing HTML files (video presentation)
Converttoutf8:st2 only supports UTF8 encoding, the plugin can display files encoded with edit GBK, BIG5, Euc-kr, EUC-JP, Shift_JIS, etc.
Clipboard History: Clipboard Histories
WordPress: Integration of some WordPress functions, for like me often write WP template and plug-ins are particularly useful!
Htmltidy: Clean and typeset your HTML code
Phptidy: Collating and typesetting PHP code
YUI Compressor: Compressing js and CSS files



Some additions:

Since Sublimetext is a green software, the user's own definition configuration, download plug-ins and so on are located in the Software folder, so once you have configured, use Dropbox, Jinshan fast disk and other synchronization network synchronization (no network friends with a USB stick), go to where to perform are their own configuration , very convenient! In the future, we can work on different computers and believe it will be very handy.
In addition, a lot of friends reflect that open Chinese will be garbled, in fact, because ST2 itself only supports UTF-8 encoding, and we often encounter the Chinese file may be GBK or GB2312 encoding, the solution is to install a ConvertToUTF8 or GBK Encoding Support plug-ins can be solved perfectly, this is not a big problem.






Related documents:

Official site: Interview
Software Nature: Toll + Free unlimited trial



Video Demo: Click to open link






Sublime Text 2 Introduction


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.