Home>Article>Development Tools> Share sublime text2 tips

Share sublime text2 tips

藏色散人
藏色散人 forward
2019-09-10 13:54:40 2633browse

In addition to its numerous practical functions and features, SublimeText2 can also install and use various extensions/skins/color schemes to enhance itself. Below, thesublime usage tutorialcolumn will share with you some tips on sublime text2.

Share sublime text2 tips

1. Quick file navigation: This is one of the very useful functions on sublime. ctrl p can bring up the window. The explanation on the menu is gotoanythings. It does exactly what it says. After calling up the window, you can directly enter keywords to quickly navigate the file name in the opened project folder. It also supports fuzzy search, which is extremely convenient for students who don’t want to keep clicking on the folder. And add: prefix to the window to jump to the row (ctrl G), add the @(ctrl R) prefix to id keyword navigation in HTML, per rule navigation in CSS, and each function in JS navigation.

2. Command line mode ctrl ` can bring up the command line mode (view->show console), which mainly supports python syntax, etc. I haven’t tried it but I know quit() can exit. . However, sublime’s plug-in platform package controller can be installed using the command line.

3. Ctrl Z to undo Ctrl Y to undo

4. Ctrl D to select words (hold down - to continue selecting the next same word String) ctrl F search is to select all the same ones on this page and then press the keyboard to replace them all

5. The default of ctrl shift F is in this project (the most used). It is also possible to search in a folder. The difference from ordinary editing is that sublime allows adding multiple folders to search (add directory)

6. ctrl L selects the entire line (hold down - to continue selecting the next line, that is) Hold down ctrl and press L once to select more than one line)

7. Ctrl Shift K deletes the entire line, Ctrl KK deletes from the cursor to the end of the line

8. ctrl / single line comment, ctrl shift/block comment (comment the selected content), sublime will automatically select the comment method according to the language

9. ctrl Enter inserts a line after the cursor Ctrl Shift Enter inserts a line before the cursor

10. ctrl F2 can add and delete marks, and then F2 switches between marks. Shift F2 goes to the previous bookmark. What is unpleasant here is that you cannot add marks with the mouse

11. Under the menu View-syntax, you can specify the current facet Syntax highlighting in the language, usually sublime will automatically judge and select

12. snippets code snippet plug-in, you can view the snippets supported by the current page under the tools-snippets menu, you can add after the abbreviation Tab automatically completes snippets. Snippets can also be expanded from installing plug-ins.

13. Build compilation can compile ruby and other codes. After I installed a yui compressor, I can compress the css js page. , the shortcut key is ctrl B, which will automatically generate xx.min.js, xx.min.css and other compressed files in the current directory

14. Under the menu Preferences are various configuration files, sublime and other editors The difference is that it does not provide visual configuration. The software configuration and shortcut key configuration are all manually configured in the .xml file. Settings-default is the system default configuration. It is best not to change it. Things to be changed are stored in Settings-User , such as font-size, etc., Key-bindings is the shortcut key configuration, color scheme is the code color scheme selection, sublime itself provides many very good color schemes

15. In the lower right corner of the page, there is a quick setting The menu of converting tabs to spaces can specify the tab width of the page, or convert all tabs on the page to the specified number of spaces

16. Other shortcut keys

ctrl [ and ctrl ] ( It has been changed to the shortcut key I am accustomed to).

ctrl up, ctrl down can scroll the screen line by line,

pageUp pageDown page by page

ctrl shift a You can HTML tag content, and go up step by step each time you press it.

ctrl shift space can select block {content} in languages such as js,

Ctrl Shift D Copy the entire line where the cursor is, and insert Before the line

Ctrl J merges lines (when multiple lines need to be merged)

Ctrl KU changes to uppercase

Ctrl KL changes to lowercase

Ctrl M The cursor jumps to the corresponding bracket (BracketHighlighter plug-in does a better job)

Ctrl Shift M Selects the content within the bracket (hold down - continue to select the parent bracket)

Alt . Close Current tag

Ctrl Shift A Select the parent tag pair at the cursor position

Ctrl Shift [Collapse code

Ctrl Shift] Expand code

Ctrl KT Collapse attribute

Ctrl K0 expand all

Ctrl U soft undo

Ctrl T word swap

Tab indent auto-complete

Shift Tab Remove indent

Ctrl Shift ↑ Swap with the upper line

Ctrl Shift ↓ Swap with the lower line

Ctrl K Backspace Delete from the cursor to the beginning of the line

17 Add smart code block prompt Tools->new snippet (save the suffix on mac machine as .sublime-snippet)

content: The code must be placed in CDATA, $1 represents the cursor position, which is convenient for editing the class name tabTrigger: shortcut key scope: the response scope can be html css js files, etc. description: the code description is in the prompt box when entering the shortcut key The introduction description text

The following introduces the highlights of sublime, the plug-in mechanism: (after installing all plug-ins, restart the software)

The sublime plug-in can be installed in two ways,

One way is to directly download all the source code and place it under C:\Users\yourName\AppData\Roaming \Sublime Text 2\Packages. The path can be viewed in the software menu bar Preferences->Browse Packages

One way is to install package control online. For package control installation, see its official website. Just run the following code in the console 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 'Please restart Sublime Text to finish installation'

After installation, you can click on the menu Open under preferences-package control (there is a shortcut key ctrl shift p which is a collection of commands for editor operations, which can be directly indexed according to keywords.). Install Package under package control is to install plug-ins. After selection, it will connect to the Internet to obtain the plug-in list. , disabled package disables a plug-in, enabled package enables the plug-in, remove package removes the plug-in, and list package lists the plug-in list.

The following introduces a few plug-ins that I think are more useful and their functions (the installation method is directly package control install and search and install online):

1. SVN: After generation, right-click the file or Folder (this costs money, if it is Windows, use TorstoiseSVN, this must be pre-installed with TorstoiseSVN)

2. BracketHighlighter: This plug-in provides matching tags, or pairing highlighting of braces or character quotes, which is regarded as Enhance system highlighting.

3. SublimeTmpl:

Customize the new file. By default, common types of panels such as html, css, and js have been added. Press ctrl alt h/ctrl alt c/ctrl alt j to create a new file. For these 3 types of files, the shortcut keys are here \Packages\SublimeTmpl\Default (Windows).sublime-keymap, and the template files are here \Packages\SublimeTmpl\templates, which can be modified.

4. ctags:

This plug-in can jump across files and jump to the place where the specified function is declared (ctrl alt left click). Use package control to search for ctags and install it (just install the ctags plug-in. There is also a CTags for PHP plug-in that is useless). Note that you need to install the ctags command after installing the plug-in. window download ctags.exe http://vdisk.weibo.com/s/7QZd7. Place the ctags.exe file in a place that can be accessed by environment variables. Open cmd and enter ctags. If this command exists, it proves successful. Install and run the command under ubuntu: sudo apt-get install exuberant-ctags. Then right-click on the sublime project folder, and the Ctag:Rebuild Tags menu will appear. Click it, and a .tags file will be generated. Then in your code, place the cursor on a function, and click to jump to the place where the function is declared.

5. sublimecodeintel:

Code tips. Sublime's default code prompt can only prompt system functions, but not functions and classes created by users. If you want to prompt the function you created. The sublimecodeintel plug-in can be installed. (You have to enter a few more characters and be case-sensitive to display, sometimes it doesn't work) Sublimecodeintel needs to be configured after installation. File: add

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

in the plug-in directory/.codeintel/config to configure the address of the python execution file. The configuration file address of python. pythonExtraPaths is a class library that requires additional code prompts. In addition to the PHP code under the current project, the python code in the directory defined in pythonExtraPaths can also be prompted. After installing sublimecodeintel, pressing alt and the left mouse button can jump to the function declaration just like ctags. But if there are two files declaring functions with the same name, sublimecodeintel will only jump to the first found function, while ctags will let you choose which file to jump to. So we generally still use ctags

6. Sublimelint (there is also a SublimeLinter that should be similar)

A plug-in that supports lint syntax, which can highlight lines of code that the linter thinks are wrong, and also supports high-level Highlight some special comments, such as "TODO", which requires some class library support, such as PHP for php - syntax checking via "php -l". Just add php to the environment variable. Execute the following statement on the command line if It can work normally because this library support has been installed when installing php, so you only need to 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 This plug-in provides ftp server management, which is very convenient for managing your own space. Yes, it is operated through configuration. After installation, restart the software, right-click on the left folder and select Map to Remote... and the sftp-config.json configuration will be generated in the folder. It is used just like SVN. Right click to

8. PHPTity: PHP code is automatically sorted. After installation and restart, ctrl alt t

9. DocBlockr: This plug-in provides file comments to facilitate the later generation of API documents based on the comments. Enter "/**" enter to call it out (the above line of the function has an effect)

10. GBK Encoding Support: sublime itself does not support GBK. According to national conditions, you can support GBK by installing this plug-in. It also provides conversion between GBK and UTF

11. jquery provides some snippets of jquery for easy direct calling

12. zenCoding There is no need to explain the famous zencoding. There are two calling methods, one is ctrl alt enter, and the other is after input Tags are tabbed directly.

13. html5 This plug-in provides many html5 related tags and other snippets, which are also very practical.

14. prefixr provides automatic filling of browser prefixes for CSS3 attributes like -webkit- -moz- -o- -m-, shortcut key: ctrl alt x

15. SCSS supports scss syntax Highlight, it comes with a lot of CSS Snippets, which can save a lot of time whether you are using them now or modifying them.

16. JS Minifer provides js compression function, based on GG's closure complier, shortcut key: ctrl alt M

17. js Format provides JS formatting function, shortcut key ctrl alt F, will According to

18. yui compressor, which everyone knows about yui's compression tool, can compress CSS JS, just CTRL B (it can only be used after jdk is installed and configured)

19. sublime v8 This plug-in provides jshint and the js parser console of the v8 engine. jshint is a JS syntax checker that is stricter, while v8 is the same as the console in chrome.

20. ClipboardHistory: This plug-in provides multiple clipboard support, you can save the contents of multiple clipboards at the same time, the ctrl alt v shortcut key calls up

The above is the detailed content of Share sublime text2 tips. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:aliyun.com. If there is any infringement, please contact admin@php.cn delete