Sublime text2 usage experience

Source: Internet
Author: User

Code Editor or text editor. For programmers, like swords and warriors, everyone wants to have a sword that can be controlled at will and is very sharp, we will also pursue a 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! If the "artifact" is the one that I can give the highest comments to a software, I am happy to block such a title for 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 not available in other editors, so that its ease of use has reached an unprecedented level ......

About sublime text 2:

Someone once 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, today's leading roleSublime text 2It is also a high-cost and high-cost representative. It is a paid commercial software with a personal license fee of up to 59 USD.

However, 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 made a purchase, the frequency is also very low. That's all. It has almost no impact if you keep using it for free. It is also worth mentioning that users can purchase an authorization and use it on different platforms at the same time, for users like me who often need to switch between MAC and win, it can save a lot of money.

Because the sublime text 2 editor has too many features and skills to use, and I am not very familiar with it, I cannot list and present them one by one. I can only choose a few features that I think are quite distinctive to introduce, in addition, there is no space 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 are far beyond the points described in this article, so this article can only be a reference, I hope you can share some good skills.

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 Automatic Code Completion functions (such as brackets and braces), Automatic completion of existing words, and automatic completion of function names), which are very 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.

Practical and convenient code prompts for complete functions

Code map, multiple interface la S, and full-screen do-not-Disturb Mode:

Sublime text 2 supports multiple la S and code maps on the interface. It also provides F11 and SHIFT + F11 to enter the full-screen do-not-Disturb Mode, which is difficult to describe.

Fully open user-defined configuration and magic and practical editing status recovery:

All the configurations of sublime text 2 are controlled by the configuration file, which can be completely customized by users. If you are willing to work hard, you can even change it 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 many 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 veryIt is not recommended to modify it here.! You can change it in the file ending with "-user" (that is, the meaning of user-defined configuration) Like a gourd. If the two sides have the same project, it is defined in the-User File.

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 combinationsFor example, by default, the key to change the selected text to uppercase is "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), which can avoid many hot key conflicts, you can also customize hotkeys in a more flexible and selective manner. However, I am not going to teach you how to modify various configurations or modify hotkeys here. I am afraid this will produce a manual. Here is a complete set of official documents (Bird's language ), if you are interested, refer to it.

In addition, sublimetext has another noteworthy detail-"Edit status recovery", that is, when you modify a file but do not save it, you exit the software, st2 does not bother prompting you if you want to save it, because no matter whether the user exits spontaneously or unexpectedly crashes and exits, your previous editing status 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 modify some places, but I don't want to save it before I make sure there is no problem. In this case, if something interrupts me and needs to leave, this feature is very useful, you can exit directly. If you are bored, you can open the software and edit it next time. 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 a very practical multi-line operation technique, which can greatly improve the editing speed! I believe that in the future, you may ask yourself, "How did I live when there was no such editor ?!"

Below are some of the multi-line editing methods 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) to select the next text and edit it at the same time;
Select the text with the mouse, and 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 (MAC) or middle mouse buttons can be used to select vertical lines;
CTRL + left mouse (WIN) or command + left mouse (MAC) You can manually select multiple texts to be edited at the same time
There are still many similar skills. Please add ......

Shift + right-click

Lightning-like 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 are a large number of files, you often need to spend a lot of energy searching in the past, 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, after you press enter, you can instantly switch over! And fuzzy match is supported. You only need to enter a part you remember. For example, if you want to find "www.iplaysoft.com. PHP file, 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 quickly switch between them.

I have seen similar functions only in large (bulky) ide such as Eclipse. However, in a small and Fast Editor, I was the first to meet it. To use this function, you can switch between open files. If you use project management (set a folder as a project ), it can also search for files that have not been opened in the matching project folder. Do you still need to use the mouse to click a tab one by one to switch between them? Do you need to open "my computer" and find the files to be edited in different folders? To use st2, you only need to enter a few characters ~ There is only one sentence: unprecedented convenience!

Jump as you like: quickly list and locate function/HTML elements, jump to a specified row

Using the Fast File switching function described above, you can easily open/switch to the document you want to edit, but if 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. Similarly, press Ctrl + P (WIN) or SHIFT + command + P (MAC) As mentioned earlier. This time, try to enter a @ number first? Well, that's good! This list will help you to list all functions in this file now! Similarly, fuzzy match is used to quickly enter several keywords and locate the function !!! This function is especially useful when you need to continuously 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 @ orPress Ctrl + RTo list all functions in the file.

Enter the @ number to start with this magic effect. Try entering a colon: start, and then enter a number. Well, this time you can jump to the specified number of rows; enter a "#" to start listing and searching text. You can also use Quick shortcuts, for example, the quick 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] vi" 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. You can 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, you can set the current document to PHP syntax highlighting; "Convert case: swap case "can reverse the case sensitivity of selected text;" file: Save all "can save all files at a time;" file: Close all "can close all files at a time ...... In addition, the list here supports Fuzzy Matching (this product is really a good thing !). Because there are too many commands and a wide range of functions, I cannot introduce them one by one here. If you are interested, you can call a panel to see what commands are in the list, learn more, try more, and digest it slowly. I believe it will make you unable to do without it any more.

Powerful Command Panel, where you can call all functions provided by sublimetext

Package control (do not miss the extension Package Manager)

In addition to its numerous practical functions and features, sublime text 2 can also be installed with various extensions, skins, and color schemes to enhance itself. The package control introduced now can be regarded as an Extension Manager of st2, you can download, install, and delete various plug-ins and skins of sublime text 2 in amazing, simple, and convenient ways. Believe me, to better use st2, you absolutely cannot leave it alone! However, st2 does not own this tool. We need to install it on our own. The method is simple:
1. Find the data> installed packages folder in the sublimetext2 directory (if not, manually create a folder)
2. Download the package control. sublime-package file here.
3. Put the downloaded file in installed packages.
4. Restart sublime text.

If package control is successfully installed, CTRL + Shift + p call the Command Panel and we will find some commands starting with "package control, we usually use several install packages (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 the number 1) to bring up the console, copy the following code and press Enter. It will automatically help you create a folder and download the file. The final 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 successfully installed, a series of commands starting with the package name will appear in the Command Panel

On the Command Panel, enter "package control: Install package" to list all the extensions that can be installed (required to connect to the network, for example). You can see from the list that, 4gl and aaapackagedev are plug-ins. You can select them to download and install them. From this list, we can see that the various extensions of st2 are already very rich! In addition, you can also see the extended list and detailed 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 briefly introduce how to install and use the plug-in sublimetext. The jsformat function is to re-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 (you can enter 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. In this case, you can only go to the web version to check some specific instructions on the use of this plug-in. This cannot be generalized here. But in general, installing and using plug-ins is so simple. With various plug-ins, You can implement almost any function you want. The plug-in API is also available for st2. If you have the ability, you can try to develop a plug-in API. 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 the skin. For example, theme-soda is a popular theme. It is basically the same as installing the plug-in. Use package control to go To the install package list 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 directory, 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 also very powerful, that is, it can native support textmate bundle and color scheme, also can be used in the packages folder. Textmate has abundant bundle and color scheme resources, which can be found on the Internet.

Big city small fat students to make the sublime text 2 of the Introduction video: http://v.youku.com/v_show/id_XMzU5NzQ5ODgw.html

 

Here are some plug-ins that I think are good. You are welcome to recommend and supplement them:

Gits: GitHub can be easily integrated
SFTP: directly edit files on the FTP or SFTP Server
Zencoding: This product is incredibly difficult for front-end students to write HTML files (video demonstration) in ultra-fast mode)
Converttoutf8: st2 only supports utf8 encoding, which can display and edit files encoded such as GBK, big5, EUC-KR, EUC-JP, shift_jis, etc.
Clipboard history: clipboard history
WordPress: integrates some WordPress functions. This is especially useful for people like me who often need 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 in the Software Directory, once you have configured it, use a synchronous Network Disk such as Dropbox and Kingsoft fast disk for synchronization (a friend without a network can also use a USB flash drive). It is very convenient to go anywhere and run it with your own configuration! In the future, we will be able to work on different computers.

In addition, many 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, which is not a big problem.

Written below:

The editor I used before is editplus. It has been used for at least four years. The main reason is that it is used to getting started quickly and for a long time, but after this trial, I did not hesitate to change to sublimetext2! In terms of various user experience, st2 gives the most people the feeling of "fast" and "smooth ". "Fast" is like the comparison between Chrome and other general browsers, so the startup speed is quite satisfactory. "smooth" means that when you are familiar with some of its quick operations, it is a sense of accomplishment to edit documents without disturbing your thoughts! As a software with so powerful functionality and scalability and so flexible configurability, it is extremely fast. Think about the large and bulky ides, you can't wait to tell everyone that there are artifacts like sublimetext in the world ~

Compared with textmate, sublime text 2 has great advantages in cross-platform and software updates. It is much easier to get started with vim, which is also an artifact-level editor, and easier and faster than all major ides, it is better than most of the online editor functions and scalability, and the dark-color interface is also very cool. It can be said that it is the best choice for another code editor besides vim and Emacs! (More modern and advanced interfaces are more suitable for common users than Vim)

Of course, the ultimate editor is like the peerless sword in the novel. It takes a long time to persevere, learn, and try to adapt to and use it flexibly. It is recommended that you learn more about and learn its shortcut keys, so writing code is like driving a chain. At present, I am just getting started, and many tips, shortcuts, and features are useless. So I hope that experts from all walks of life will not be enlightened. I will share some st2 practical skills and tutorials with me, thank you!

Original article: http://www.iplaysoft.com/sublimetext.html

Sublime text2 usage experience

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.