Sublime Text 2 Tips

Source: Internet
Author: User
Tags parse error



1. File Quick navigation: This is sublime above very useful function, ctrl+p can bring up the window, the explanation on the menu is gotoanythings, indeed, as it says, after the window is paged, directly enter the keyword, you can open the project folder for quick file name navigation, and support fuzzy Search, for the students do not want to keep the mouse point open folder is very convenient, and in this window added: prefix is the line jump (ctrl+g), plus @ (ctrl+r) prefix in the HTML is the ID keyword navigation, CSS is each rule navigation, JS is each function navigation.



2. Command-line mode CTRL + ' can call up command-line mode (View->show console), mainly support Python syntax, etc., did not try to know only quit () can exit. However, the sublime plug-in platform package controller can be installed with the command line.



3. Ctrl + Z undo ctrl+y Recovery Undo



4. Ctrl+d Word selection (press and hold-continue to select the next same string) Ctrl+f find is the same as selecting this page all the same and then press the keyboard to replace the full replacement



5. Ctrl+shift+f default is in this project (most used). It can also be found in folders, unlike regular editors, where sublime allows multiple folders to be found (add directory)



6. ctrl+l Select the entire row (press and hold-continue to select the following line, that is, hold down CTRL and do not press the L to choose one more row)



7. Ctrl+shift+k Delete entire line, CTRL+KK from cursor to end of line



8. ctrl+/single-line comment, ctrl+shift+/block Comment (note selected content), Sublime automatically selects annotation by language



9. Ctrl+enter Insert Line after cursor ctrl+shift+enter cursor before inserting



CTRL+F2 can make the add-on tag, and then F2 switch between the tags, shift+f2 the previous bookmark. It's not right here. Mouse tagging is not possible



11. Under Menu View-syntax, the current quilt can be highlighted in the specified language, usually sublime will be judged automatically.



Snippets Code snippet plug-in, under the Tools-snippets menu can see the current page support snippets, can be added after the abbreviation tab auto-complete snippets, snippets can also be extended from the installation plug-in



Build compile, you can compile code such as Ruby, I installed a YUI compressor, you can compress in the CSS JS page, shortcut keys are ctrl+b, will automatically generate xx.min.js in the current directory, Xx.min.css and other compressed files



14. In the menu preferences below is a variety of configuration files, sublime unlike other editors, he does not provide visual configuration, software configuration and shortcut configuration are all present. xml file manually configured, Settings-default is the system default configuration, Better not change, to change things stored in settings-user, such as Font-size, Key-bindings is the shortcut configuration, color scheme is the Code color scheme selection, sublime itself provides a lot of very good color scheme



15. In the lower right corner of the page, there is a quick set tab to Spaces menu, you can specify the tab width of the page, or you can convert all tab tabs to the specified number of spaces



16. Other shortcut keys


Ctrl+[ and ctrl+] (has been changed to the shortcut keys I am used to).
    Ctrl+up, ctrl+down can scroll the screen line by line.
    pageUp pageDown page flip
    Ctrl+shift+a can HTML tag content, each time you press it up,
    Ctrl+shift+space can select the block {content} in languages such as js.
    Ctrl+Shift+D copies the entire line of the cursor, inserted before the line
    Ctrl+J merge rows (when multiple rows that need to be merged have been selected)
    Ctrl+KU to uppercase
    Ctrl+KL to lowercase
    Ctrl+M cursor jumps to the corresponding parenthesis (BracketHighlighter plugin does a better job)
    Ctrl+Shift+M to select the contents of the brackets (press and hold - continue to select the parent brackets)
    Alt+. Close the current tab
    Ctrl+Shift+A selects the cursor position parent label pair
    Ctrl+Shift+[fold code
    Ctrl+Shift+] expand code
    Ctrl+KT collapse attribute
    Ctrl+K0 Expand all
    Ctrl+U soft undo
    Ctrl+T word interchange
    Tab indentation autocomplete
    Shift+Tab removes indentation
    Ctrl+Shift+↑ swaps with the upstream
    Ctrl+Shift+↓ swaps with the downlink
    Ctrl+K Backspace is deleted from the cursor to the beginning of the line 


17 Add smart code block hint tools->new snippet (save suffix for. Sublime-snippet under Mac Machine)



Content: Put code must be placed in CDATA, the position of the cursor, convenient to edit the class name Tabtrigger: Shortcut key scope: The response range can be HTML CSS JS file, such as Description: code description in the input shortcut key in the description of the box Text



Next introduce the bright spot of sublime, plug-in mechanism: (Install all the plugins to restart the software)



The sublime plugin can be installed in two ways,



A direct download of all source code placed below the C:\Users\yourName\AppData\Roaming \sublime Text 2\packages, the path can be in the Software menu bar Preferences->browse Packages view



One can be installed online through the installation of the package control, the package control installed on its official website, in the console run the following code, and then restart:


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 ' Restart Sublime Text to finish installation '


After installation can be opened under the menu Preferences-package control (here is a shortcut key ctrl+shift+p is the editor operation of the command collection, can be directly based on the keyword index.), install under the package control Package is to install plug-ins, select the network to get a list of plug-ins, disabled package is to disable a plug-in, enabled package enable plug-ins, remove package removal plug-in, list package lists plug-in lists.



Here are a few I think more useful plug-ins, and its function bar (installation Method direct package control install online search installation):



1. SVN : Right-click on the file or folder after the build (this wants money, if it is windows, use TORSTOISESVN, this should be preinstalled TORSTOISESVN)



2. Brackethighlighter : The plug-in provides pairing tags, or curly braces or character quotes paired highlighting, is the system highlighting the enhancement bar.



3. Sublimetmpl :



Customize the new file. The default has been added HTML, CSS, JS and other common types of panels, press CTRL+ALT+H/CTRL+ALT+C/CTRL+ALT+J can create a new 3-clock type of file, shortcut keys here \packages\sublimetmpl\ Default (Windows). Sublime-keymap, template files are \packages\sublimetmpl\templates here and can be modified.



4. Ctags :



This plugin can jump across files and jump to the specified function declaration (ctrl+alt+ left button). Use the package control to search CTags for installation (install the CTags plugin is OK, there is a CTags for PHP plug-in is not a good use), note that after installing the plug-in need to install the CTags command. Window Download Ctags.exe http://vdisk.weibo.com/s/7QZd7. Place the Ctags.exe file where an environment variable can be accessed. Open cmd, enter ctags, if there is this command, proves successful. Ubuntu under Install Run command: sudo apt-get install exuberant-ctags. Then in the Sublime project folder right-click , the Ctag:rebuild Tags menu will appear. Click on it, then generate the. tags file and then in your code, the cursor is placed on a function, click on it to jump to the function declaration place.





5. Sublimecodeintel :



Code hints. Sublime The default code hints can only prompt system functions, the user creates their own functions, classes cannot be prompted. If you want to prompt yourself to establish a function. You can install the Sublimecodeintel plugin. (To lose more than a few characters and case sensitivity to show, sometimes not) Sublimecodeintel installation needs to be configured, files: add-ons directory/.codeintel/config


 
{
    "Python": {
        "python" : "D:\servers\python27",
        "pythonExtraPaths": [
            "libs",
            "~/Applications/Sublime Text 2.app/Contents/MacOS",
            "/Applications/Sublime Text 2.app/Contents/MacOS"
        ]
    }
}


The address of the Python executable file is configured, Python's profile address, Pythonextrapaths is the class library that requires additional code hints. In addition to the current project PHP code can be prompted outside the pythonextrapaths defined in the directory of Python code can also prompt. After installing Sublimecodeintel, press ALT + left mouse button to jump to the function declaration as well as Ctags. But if you have two files that declare a function of the same name, Sublimecodeintel will only jump to the first found function, and ctags will let you choose which file to jump to. So we usually use the ctags.



6. sublimelint (another sublimelinter should be the same)



A plugin that supports lint syntax can highlight the lines of code that Linter think is wrong, and also support highlighting special comments, such as "TODO", which requires some class library support such as PHP php-syntax checking via "php-l". To add PHP to the environment variable. Execute the following statement on the command line if it works correctly, it can be loaded because the library is supported when loading PHP, so just add PHP to the environment variable.


 
The syntax for checking is like this, where the -l flag is a lower case L:

php -l filenameIf the syntax in the file is correct you will see this:
No syntax errors detected in test.phpIf there are errors then theses will be listed as in the following example output:
Parse error: syntax error, unexpected T_STRING in test.php on line 5
2Errors parsing test.php


7. SFTP The plug-in provides FTP server management, to manage their own space is very good, through the configuration to operate. After you restart the software after installation, right-click on the left folder to select Map to Remote ... The Sftp-config.json configuration can be generated under the folder, using the same time as the SVN right-click



8. phptity:p HP Code automatic sequencing. Ctrl+alt+t after reboot



9. Docblockr : This plug-in provides file comments to facilitate late generation of API documentation according to comments, enter "/**" + Enter call up (on the function of the line is effective)



GBK Encodingsupport: Sublime itself is not supported by GBK, according to national conditions, installed this plug-in can support GBK, but also provides the conversion between GBK and UTF



jquery provides some of the snippets fragments of jquery, which makes it easy to call directly



zencoding Famous zencoding do not have to explain, call way two, one is Ctrl+alt+enter, one is to enter the label directly after the tab.



HTML5 The plug-in provides many HTML5-related labels snippets, and is also very useful.



PREFIXR The browser prefix that provides the CSS3 property is automatically populated like-webkit--moz--o--m-, shortcut key: ctrl+alt+x



SCSS Support SCSS syntax highlighting, which comes with a lot of CSS Snippet, whether it is used or converted into, can save a lot of time.





JS minifer provides JS compression function, based on GG closure complier, shortcut key: ctrl+alt+m



JS Format provides JS formatting function, shortcut key ctrl+alt+f, will be based on



Yui Compressor This everyone knows Yui's compression tool, you can compress CSS JS, direct ctrl+b, you can (need to install the JDK after configuration is available)



Sublime V8 The plugin provides jshint and V8 the JS parser console,jshint is the JS grammar checker, stricter, V8 is the same as the Chrome console.



clipboardhistory: The plugin provides multi-clipboard support, you can save multiple clipboard contents at the same time, ctrl+alt+v shortcut keys to recall



Sublime Text 2 Tips


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.