Sublime Configuration Overview

Source: Internet
Author: User
Tags beautifier

Hello everyone, today I will share with you an Editor: sublime text2
I have used many editors,
Editplus, emeditor, notepad ++, notepad2, ultraedit, editra, Vim, and netbeans, zendstudio, and Dreamweaver. Finally, I met sublime text. Sublime is the best editor I have ever seen. You can use sublime to install corresponding plug-ins for functions that can be implemented by large ides. It is a small editor that runs fast. Now is the time to take the courage to replace your previous editor. If you have never heard of sublime before, you can see this introduction video: http://v.youku.com/v_show/id_XMzU5NzQ5ODgw.html

Sublime itself has limited functions. We need to install some plug-ins to make it powerful. Sublime can be run in various operating systems, but you need to pay attention to Chinese input when running it in Linux. Next I will introduce the common plug-ins, configuration suggestions, and precautions for running in Linux.

I. Common plug-ins

1. Package control. We almost always use sublime to install this plug-in first. This plug-in is a function for managing plug-ins. It is convenient to install other plug-ins first. Installation Method:
Click View-> show console in the sublime menu bar. Now the console is opened, which has two upper and lower columns. The above column displays the plug-ins executed by sublime in real time and outputs the execution results, if a plug-in you installed does not run properly, check whether an error is reported. The following is an input box for running Python code. Enter the following code and press enter to run the package control.

    1. Import urllib2, OS; pF = 'package control. sublime-package '; IPP = sublime. installed_packages_path (); OS. makedirs (IPP) if not OS. path. exists (IPP) else none; open (OS. path. join (iPP, PF), 'wb '). write (urllib2.urlopen ('HTTP: // sublime.wbond.net/'{pf.replace ('', '% 20 ')). read ())
Copy code
Then press Ctrl + Shift + P. In this case, an input box is output and install is input. Select package contrl: Install package and press Enter. You need to wait a moment. The status bar in the lower-right corner will display the prompt text that is being connected. When using sublime, pay attention to the status bar in the lower right corner. Many plug-in prompts are displayed here. This status bar is very small and may not be noticed by people who use it for the first time.

<Ignore_js_op>

After a while, it will display a list of plug-ins. You can also enter text in the input box to search for plug-ins. Find the plug-in you want to install, select it, and press Enter. It will be automatically installed for you.

If you want to uninstall the plug-in, press Ctrl + Shift + P and enter remove. Select package control: Remove package and then select the installed plug-in. Press enter to uninstall the plug-in.

If package control fails to install the plug-in, we can manually install the plug-in, search for the plug-in on Google, and download the plug-in source code. In the sublime menu bar, click preferences-> browse package .. the plug-in directory will be opened. Then copy the source code of the plug-in you downloaded.

What is the panel of the input box opened by Ctrl + Shift + P? The English name is "Anything panel". Any operation can be done in this panel. I will translate it into "Universal panel" for the moment ". There are several ways to open the universal panel.
When Ctrl + Shift + P is enabled, we need to enter a command in the panel and then execute the command. You can enter a command to perform operations on all menu bar operations.
When Ctrl + P is opened, you can quickly find the file.
When Ctrl + R is enabled, you can find functions in the current file.
When Ctrl + G is enabled, you can jump to the specified row.

When people started to access sublime, they were not very familiar with its environment. I have mentioned a little more here. Let's briefly summarize what we mentioned above.

The role of the console: You can execute Python code here and view some execution results. If the plug-in is not running properly, you can check whether an error is reported here.
Status Bar in the lower-right corner: A lot of prompts will be displayed there, and you should check them frequently.
Universal panel: All operations can be performed here. You can enter commands here, search for files, or search for functions here.
Plug-in Installation Method: In addition to package control installation, you can also manually install the plug-in.

2. ctags. This plug-in can jump to the specified function declaration place across files. Use package control to search for ctags for installation (you can install the ctags plug-in, and a ctags for PHP plug-in is useless ). After installing the plug-in, install the ctags command. Window to download the ctags.exe http://vdisk.weibo.com/s/7QZd7. Place the ctags.exe file in a place where environment variables can be accessed. Open CMD and enter ctags. If this command exists, it indicates that the command is successful. Run the following command on Ubuntu: sudo apt-Get install exuberant-ctags.
Right-click the sublime project folder and the CTAG: rebuild tags menu is displayed. Click it to generate the. tags file.
<Ignore_js_op>

In your code, place the cursor on a function, and click Ctrl + Shift + the left mouse button to jump to the function declaration.

3. sublimecodeintel code prompt. The default sublime code prompt only prompts system functions. The user-created functions and classes cannot prompt. If you want to prompt yourself to create a function. You can install the sublimecodeintel plugin.
<Ignore_js_op>
Sublimecodeintel must be configured after installation. The file is added to the plug-in directory/. codeintel/config.
    1. "Php ":{
    2. "Php": 'd: \ saeserver \ PHP \ php.exe ',
    3. "Phpextrapaths": ['d: \ saeserver \ PHP \ stdlib '],
    4. "Phpconfigfile": 'd: \ saeserver \ apache \ PHP. ini'
    5. },
Copy code
The PHP Execution file address and PHP configuration file address are configured. phpextrapaths is a class library that requires code prompts, in addition to the PHP code in the current project, the PHP code in the directory defined in phpextrapaths can also be prompted. D: \ saeserver \ PHP \ stdlib is the directory of the SAE local simulated file in saeserver. Therefore, the prompt for Sae code is displayed wherever it is configured.

After installing sublimecodeintel, press Alt + the left mouse button to jump to the function declaration area like ctags. However, if two files declare functions with the same name, sublimecodeintel will only jump to the first function found, and ctags will let you select the file to jump. So we usually use the jump function of ctags.

4. Syntax prompt. If a syntax error occurs during code writing, we can immediately prompt you to install these two plug-ins: sublimelint and phpcs. sublimeint requires the system to have PHP commands. Therefore, you need to set the PHP environment variables. The sublimelint syntax error prompt is displayed on the status bar. Therefore, when writing a program, always check the status bar. The syntax error message of phpcs is that an error is displayed on the universal panel when the file is saved. The error message of sublimelint is real-time but not obvious. The error message of phpcs is not real-time, but it is obvious. Therefore, we usually need to install these two plug-ins. In addition to code prompts, phpcs also have other functions, but I have not figured out how to use other functions for the moment. You can study them. If you know how to use them, let me know.

5. Goto document. This plug-in can help us quickly view the manual. For example, when we were writing PHP code, we suddenly forgot how to use a function, put the mouse over the function, and then press F1, it can quickly go to the PHP manual to describe how to use this function.
After installing the Goto document plug-in, we can configure the shortcut key F1 to jump to the document. Open the sublime menu bar preferences-> key bindings-user to set the shortcut key:
    1. [
    2. {"Keys": ["f1"], "command": "goto_documentation "}
    3. ]
Copy code After this setting, Press F1 to jump to the document.

6. function name display. This plug-in shows the function in which the current cursor is located in the status bar.

7. GBK encoding support. Sublime itself does not support GBK encoding. you can install this plug-in to support it.

8. SVN plug-in. In Windows, you can install the tortoise and tortoisesvn clients. In sublime, you can submit SVN by right-clicking the directory or file. In ubuntu, rabbitvcs can be installed with this plug-in: The https://github.com/kervin/sublime-svn/downloads achieves the same functionality.

9. Gist. When creating an HTML file, we do some same code. At this time, we like to have a code template. We cannot write the same code repeatedly. The gits plug-in can implement the Code Template Function. It can be seen in the code template we have created. The code snippets are kept under gist in GitHub. Http://lucifr.com/2012/03/07/sub... Al-snippet-Manager/here detailed usage is introduced.

10. code annotation formatting.

The additional Php snippet plug-in prompts the phpdocument format code.
<Ignore_js_op>

You can also quickly output open-source protocols. Input PHP-a prompt will be displayed.
<Ignore_js_op>

Install the docblockr plug-in to form a comment block. You do not need to press a slash or Asterisk for each comment.

11. Paired matching enhancement. These symbols are paired with braces {}, braces [], Parentheses (), and quotation marks. When we move the cursor over the start symbol, we hope to clearly see where the end symbol is. The Sublime is underlined by default, which is not obvious. To be clear, we can install the plug-in brackethighlighter.


12. format the PHP code. Install the PHP-beautifier plug-in. To use PHP-beautifier, you also need to install the pear package of PHP beutifier:
Pear install php_beautifier
After the installation, open the PHP file and press CTRL + ALT + F to automatically format the code.



Add to favorites 7Forward to Weibo
 

Report

   
Luofei614

Beginner programmers

  • String door
  • Add friends
  • Greeting
  • Send message
Sofa Posted on 16:44:15 | View the author only
This post was last edited by luofei614 at, January 3 ,.

13. xdebug. You can install the xdebug plug-in for code debugging. This is a function available in large IDES and is rarely available in small editors, but the sublime plug-ins can implement the xdebug function.
<Ignore_js_op>

Your PHP needs to install the xdebug extension. Create a. sublime-project file in the project directory.
    1. {
    2. "Folders ":
    3. [
    4. {
    5. "Path": "D: \ ysd \ ysdv8"
    6. },
    7. ],

    8. "Settings ":{
    9. "Xdebug": {"url": "http://yunshangdian.com "}
    10. }
    11. }
Copy code The path configuration item configures the path of the program.
Note: Set a breakpoint for the program. Otherwise, you cannot see the effect. For detailed usage, see: https://github.com/Kindari/SublimeXdebug

If you want to write front-end code, you can also install some plug-ins related to HTML and Js. Such as zencoding, jquery, jquery mobile snippets, and jquery snippets pack.

2. Configuration recommendations.


Recommended user configuration (open the menu bar preferences-> setting-user ):

{
"Color_scheme": "packages/color scheme-default/monokai. tmtheme ",
"Default_line_ending": "Unix ",
"Detect_slow_plugins": false,
"Font_face": "Microsoft yahei ",
"Font_size": 10.0,
"Auto_match_enabled": false,
}

If auto_match_enabled is set to false, auto-completion of parentheses can be disabled. For example, when we input the left parenthesis, sublime automatically typed the right parenthesis. We often don't like this. In this case, set auto_match_enabled to false.

Recommended shortcut key configuration (menu bar preferences-> key bindings-user ):


[
{"Keys": ["f1"], "command": "goto_documentation "},
{"Keys": ["Alt + Shift + '"], "command": "clone_file "}
]

F1 quickly open the document. The setting of this shortcut key has been mentioned earlier.
What is the use of ALT + Shift + 'shortcuts? We need to open the same file in both the left and right columns.

<Ignore_js_op>

Press the shortcut key: Alt + Shift + 2. The layout of the left and right columns is displayed.

Press Alt + Shift + '(The 'key is the key above the tab key). At this time, a copy of the current file will be copied, and then the newly copied file will be dragged to the right column. In this way, the left and right columns of the same file are opened simultaneously.

Switch back to the layout column and press Alt + Shift + 1

Recommended color settings:

When the sublime is invalid (invalid), an error is often prompted. The color is ugly. You can remove the color prompt for invalid.
In the \ color scheme-Default \ monokai. tmtheme file under the plug-in directory, delete

    1. <Dict>
    2. <Key> name </key>
    3. <String> invalid </string>
    4. <Key> scope </key>
    5. <String> invalid </string>
    6. <Key> Settings </key>
    7. <Dict>
    8. <Key> background </key>
    9. <String> # f92672 </string>
    10. <Key> fontstyle </key>
    11. <String> </string>
    12. <Key> foreground </key>
    13. <String> # f8f8f0 </string>
    14. </Dict>
    15. </Dict>
Copy code





Matching in pairs is green by default, which is a little ugly,

In the \ color scheme-Default \ monokai. tmtheme file under the plug-in directory, in the class name key:
Changed:

    1. <Dict>
    2. <Key> name </key>
    3. <String> class name </string>
    4. <Key> scope </key>
    5. <String> entity. Name. Class </string>
    6. <Key> Settings </key>
    7. <Dict>
    8. <Key> background </key>
    9. <String> # f92672 </string>
    10. <Key> fontstyle </key>
    11. <String> </string>
    12. <Key> foreground </key>
    13. <String> # f8f8f0 </string>
    14. </Dict>
    15. </Dict>
Copy code



3. Use it in Linux.

In Linux, you cannot enter Chinese characters. You can use the scim input method to solve this problem. The specific solution: http://www.haogongju.net/art/1312281
Although scim allows us to enter Chinese characters, it is not perfect. If the candidate words do not follow, the candidate words will disappear after sublime is defocus. If the candidate word disappears, you can temporarily resolve the problem by separating sublime into a separate workspace.

Sublime Configuration Overview

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.