search
HomeDevelopment ToolssublimeShare sublime text2 tips

Share sublime text2 tips

Sep 10, 2019 pm 01:54 PM
sublime

In addition to its numerous practical functions and features, SublimeText2 can also install and use various extensions/skins/color schemes to enhance itself. Below, the sublime usage tutorial column 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. If there is any infringement, please contact admin@php.cn delete
Sublime Text: The Price and Its Value PropositionSublime Text: The Price and Its Value PropositionApr 13, 2025 am 12:06 AM

The license price of SublimeText is $99, which is worth buying because: 1) it provides an efficient editing experience and improves work efficiency; 2) it has a rich plug-in ecosystem to meet personalized needs; 3) it supports cross-platform use and is suitable for different operating systems; 4) it can receive continuous updates and technical support after purchase.

Sublime Text: Customizable and Efficient Code EditingSublime Text: Customizable and Efficient Code EditingApr 12, 2025 am 12:08 AM

SublimeText is a powerful and highly customizable editor. 1) It supports multiple programming languages ​​and provides functions such as multi-line editing, code folding, etc. 2) Users can customize through plug-ins and configuration files, such as using PackageControl to manage plug-ins. 3) Its underlying layer is based on Python, supports multi-threading and GPU acceleration, and has excellent performance. 4) Basic usage includes shortcut key operations, and advanced usage involves macros and Snippets. 5) Frequently asked questions such as failure to install the plug-in, it can be solved by checking the network and updating it. 6) Performance optimization suggestions include cleaning up plug-ins and using cache reasonably.

Sublime Text: License Details ExplainedSublime Text: License Details ExplainedApr 10, 2025 am 09:34 AM

SublimeText's license is a permanent digital key that unlocks all features and removes trial tips. After purchase, it is activated through the official website. The same key can be used for personal use by multiple devices, so you must avoid violations of the terms of use.

Sublime Text Package Control: Mastering Package ManagementSublime Text Package Control: Mastering Package ManagementApr 09, 2025 am 12:08 AM

PackageControl improves the development experience of SublimeText through the following steps: 1. Install PackageControl and use a few lines of command to complete it. 2. Access PackageControl through shortcut keys or menus to install, update and delete plug-ins. 3. Regularly clean and update plug-ins to optimize performance and improve development efficiency. Through these operations, developers can focus on programming and improve the overall development experience.

Sublime Text Project Management: Organizing and Navigating CodebasesSublime Text Project Management: Organizing and Navigating CodebasesApr 08, 2025 am 12:05 AM

SublimeText's project management function can efficiently organize and navigate the code base through the following steps: 1. Create a project file and save the .sublime-project file using SaveProjectAs in the Project menu.... 2. Configure project files, specify the included folders and settings, such as excluding specific files or setting up the build system. 3. Open the project file and quickly load the project environment through OpenProject in the Project menu. 4. Optimize project files to avoid including too many folders, and use the exclusion mode to improve navigation speed. Through these steps, you can use SublimeText's project management capabilities to improve development efficiency and code quality.

Sublime Text Command Palette: Unleash the Power of SublimeSublime Text Command Palette: Unleash the Power of SublimeApr 07, 2025 am 12:17 AM

Using the CommandPalette of SublimeText can improve productivity. 1) Open CommandPalette (Ctrl Shift P/Windows/Linux, Cmd Shift P/Mac). 2) Enter the command keyword, such as "InstallPackage" or "DarkTheme". 3) Select and execute commands, such as installing plug-ins or switching themes. Through these steps, CommandPalette can help you perform various tasks quickly and improve the editing experience.

Sublime Text Regular Expressions: Mastering Search and ReplaceSublime Text Regular Expressions: Mastering Search and ReplaceApr 06, 2025 am 12:15 AM

Search and replace using regular expressions in SublimeText can be achieved through the following steps: 1. Turn on the search and replace function, using the shortcut keys Ctrl H (Windows/Linux) or Cmd Opt F (Mac). 2. Check the "regular expression" option and enter the regular expression mode to search and replace. 3. Use the capture group to extract matching content, for example, use https?://(1) to extract the domain name in the URL. 4. Test and debug regular expressions to ensure that the required content is correctly matched. 5. Optimize regular expressions to avoid over-match and use non-greedy matching to improve performance. /↩

Sublime Text Build Systems: Compiling and Running Code DirectlySublime Text Build Systems: Compiling and Running Code DirectlyApr 05, 2025 am 12:12 AM

SublimeText's BuildSystems can automatically compile and run code through configuration files. 1) Create a JSON configuration file and define the compilation and running commands. 2) Use shortcut keys to trigger BuildSystems to execute the command. 3) Optimize configuration to improve performance, such as using cache and parallel compilation. This allows developers to focus on writing code and improve development efficiency.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.