Home > Article > Backend Development > Sublime Text 3 development php
It has been 4 months since the first unboxing review, but because of laziness, there is no further post. Finally, today, I feel like writing a quasi-technical article.
I forgot how I started using ST. I probably started using it after seeing recommendations from others online. I have been using it for half a year. It is an absolute artifact under Windows, unparalleled by Notepad++ and the like; under Linux, because there is vim, I don’t understand vim, so it’s hard to say which one is better. To sum up, it is an artifact-like lightweight text editor for php, python and other developers. It is quite good and recommended to you. I mainly use it to write PHP, it is really easy to use. It may also be useful for writing
python; I don’t know what the situation is like when writing ruby, and whether anyone has used it to write. In short, ST is more suitable for writing some scripting languages. As for C#, Java, etc., it is better to use traditional and classic IDEs. 1. Install Sublime Text 3
Official website http://www.sublimetext.com/3
Be sure to choose ST3 instead of ST2, 3 is easier to use than 2, really, You'll find out later.
Choose the corresponding version to install. After completion, you need to install a basic and necessary package management: Package Control, which will be used to install plug-ins in the future.
Package Control Installation
Installation Guidehttps://sublime.wbond.net/installation
Open ST3, click on the menu View -> Show Console , will A command input box appears at the bottom, then copy the above command into the input box, press Enter, wait, and the installation is successful.
2. Plug-in installation
After installing Package Control above, we can open Package Control through the shortcut key Ctrl+Shift+P to install the plug-in. Enter install in the open input box, and you will automatically be prompted to select Install Package based on your input.
Wait, and then an input box will pop up, allowing you to enter the plug-in you want to install.
We want to install a plug-in that supports UTF8 encoding. We only need to enter convert in the input box. After automatic matching, select the ConvertToUTF8 plug-in, press Enter, wait, and the installation is complete. In this way, ST supports UTF -8 encoded.
I think it is a must-install plug-in
ery is mostly applicable to other languages, please make your own choice)
1. ConvertToUTF8
Plug-in that supports UTF-8 encoding2. Bracket Highlighter
Used to match brackets, quotes and html tags. Useful for very long codes. After installation, there is no need to set up the plug-in and it will automatically take effect3. DocBlockr
DocBlockr can automatically generate PHPDoc-style comments. The languages it supports include Javascript, PHP, ActionScript, CoffeeScript, Java, Objective C, C, C++4. Emmet (Zen Coding)
A plug-in that quickly generates HTML code snippets. It is unparalleledly powerful. If you don’t know, please ask Google by yourself5. SideBar Enhancements
This plug-in improves the sidebar and adds many functions6. Theme management, when switching themes, you don’t need to modify the configuration file yourself, use this You can easily switch themes
Please refer to http://www.ladyloveit.com/sublime/developers-commonly-used-10-sublime-text-plugin
3. General shortcuts Keys
Understanding and mastering the shortcut keys will allow you to move quickly. So, let’s take a look at some useful shortcut key operations in ST. Here I will only talk about the ones I usually use during development. Complete Readers are asked to google for shortcut key operations.
1.
Ctrl+Shift+P
Open Package Control, which has been introduced above. There is another trick here, which can be used in various places below, that is, ST supports fuzzy matching. For example, if you want to find an Install Package, you can install it in the input box of Package Control and it will be automatically matched to the Install Package. You can also simply enter the IP address and it will be matched. This fuzzy matching function is very convenient.
Ctrl+P
Open the file based on the file name. For example, if you want to open login/func/funtion.php, you only need to enter login/func/funtion.php in the input box. You can also use fuzzy matching, such as login/function, etc. You should do fuzzy matching yourself. Experience it.
3. After finding the source code file we want to view, what should we do if we want to find function methods?
Ctrl+R
Enter log to find all methods with log in their names. Enter loginout to locate loginout().
You may notice that after Ctrl+R, there will automatically be an @ in the input box, which means to match the method. Well, in addition to this, there are some useful matching symbols, which I will mention together.
After locating the line , Ctrl+G, or Ctrl+P, enter: the number of lines in the box, such as: 58, then jump to line 58.
Look for the logo , followed by Ctrl+P, # logo.
4. After learning the above shortcut operations, you can basically play ST. Being able to write PHP in ST is no longer a problem. It is very satisfying to switch between various files and quickly jump to methods. But if you want to use it more comfortably, smoother, and smooth as silk, you can also look at the following
Synchronized editing in multiple places, Ctrl+D, I often use this function, it is very good.
When you want to modify multiple identical codes at the same time, for example,
$user['name'] = 'bananaplan';
$user['age'] = 28;
$user['desc'] = 'I want to be 28 years old forever';
The user in
in user , ’’’” being all changed to “member”, user can be selected by double-clicking it, and then Ctrl+D will be selected continuously downwards. Repeat , until you are satisfied with the position, and then you can edit it uniformly.
---->
Someone said, Tsk, this is nothing, you can completely use search and replace. Yes, search and replace can be achieved, but this method is more convenient for me. It's more intuitive and less error-prone. As the saying goes, heroes see each other differently, so please judge for yourself.
In fact, in addition to using the Ctrl+D shortcut key, there is also a way to use the mouse to achieve continuous selection. Hold down Ctrl and double-click to select multiple items.
In fact, in addition to the above two ways to achieve simultaneous editing, there is another way. That is, hold down Shift, then hold down the right mouse button, and finally, pull down vertically. This method has limitations, that is, it can only be selected vertically. It is suitable for scenarios where the code segment is a bit long, as follows
5. It feels like writing like this is too crippled. I can’t be so detailed. Let’s put it below The important details are written in detail and can be found on the Internet, so just briefly talk about it
What I’m going to talk about below is commonplace for everyone, but I still want to talk about it.
Ctrl+F, search, I won’t say much about the options on the left, just read the prompts yourself, in English, it tells you not to study English well, by the way, now the college entrance examination seems to be gradually weakening the weight of English. Note that at the bottom, you will be prompted for 2 of 5 matches. A total of 5 matches have been found. The one you are matching now is the second one. I think this tip is very useful.
After Ctrl+F, Enter
finds the next one,Shift+Enter, finds the previous one.
Ctrl+H, search and replace, not much to say.
Ctrl+Shift+F, this one needs to be bold and red, just point at it and it’s alive. How to put it, it can be called full-project search, which means searching in the project you are currently opening based on the characters you input. As above, we look for files containing have_posts in the wp folder. In just a few words, I may not be able to tell you all about its usage, so please experience it yourself.
intule’sWhen I only used NotePad++, I wrote a PHP script to implement this function in order to realize full-text search and replacement. ----------I feel tired from writing. This job is really hard to do. Writing a blog seriously is not easy. There seems to be nothing to describe in detail about the remaining shortcut keys. Please refer to the online information by yourself ---------- http://ce.sysu.edu.cn/hope /Item/106853.aspx 4. Let’s talk about the benefits of ST 1. PHP code automatic prompt; and existing string automatic prompt Leverage It's easy to use, the PHP code automatically prompts, no need to explain. There is already an automatic prompt for strings, please see the picture below $st_so_powerful is not a built-in variable in PHP, but it can have automatic prompts because it already exists in the code, so it can prompt that it already exists characters, this function can greatly save your time typing code. 2. Code template, quickly generate code If you type ifelse, it will help you quickly generate an if else code template. The key is that corresponding content will be generated in the PHP code and in the HTML code. It is difficult to explain in words. Please look at the picture below. Generated in the PHP code I won’t explain. Yes, please enlighten yourself. ules Me in code generated keywords in HTML: php echo if ifelse foreach, is that enough? Not enough? ? ? Oh, for the advanced usage of this piece of code template customization, please google: Sublime Text Snippet You have to come back and make up for it, otherwise you may have to scold me. Because after you entered if, there was no response. You have to press the Tab key, brother. 3. I’m really tired of writing, so let’s end it. Put a heavyweight bombshell function at the end. Please note that this function is only valid in ST3 Why do I use an IDE? , by the way, first let me tell you which IDE I use, that is the very easy-to-use Zend Studio. I only care about its two functions: 1. Code jump, that is, jump to the place where the variable or function is defined; 2. Function Where is it referenced (this is a heavyweight killer feature that no other PHP IDE I have tried has). Of course you can’t expect our little ST to have this heavyweight killer function, but now ST3 has the first function, which is code jump, which can jump to the place where the function is defined. The significance of this feature is that you can now use ST3 to replace other non-Zend Studio IDEs, really. Above: If the function you want to jump to is defined in only one file, jump directly to it; otherwise, you will be provided with options to choose which file to jump to. Although this function is not as smart as Zend Studio (Zend jumps to the corresponding file directly and intelligently), it is already very good, isn't it? Yah, I need to make up for it again. I am getting older and my brain is not working well. Forgot to mention the jump method, select the called function method name, click F12, and you can jump to it. If the F12 shortcut key is occupied, please modify the default shortcut key and customize the shortcut key to jump to the function. It can be customized as { "keys": ["f3"], "command": "goto_definition" } , because I used to write Java and have used Eclipse for many years, so I am used to F3 jumping to functions, so readers can do it at their own convenience. As for how to customize shortcut keys, please google 4. Although I was tired of writing and published it, I suddenly remembered that there is another very important function that I have to say, so I came back to add it That is , add the folder to the project, click the menu
Project -> Add Fold To Project, just select the folder you want to add to the project. When you add many folders to the project, you will find a small problem, that is, when Ctrl+P switches files, the list of options is a bit long. That is because you have many projects, maybe There will be many files with the same name, and the project list on the left doesn't look clean. What? If you don't see the item list on the left, please click View -> Side Bar -> Show Side Bar. So, we can occupy one workspace for one project, and switch to whichever project we want to write. Specific operation: After you add a folder to the project, click the menu
Project -> New Workspace For Project, create a workspace for this separate project. Note that there must be only one project currently. If there are two or more projects, then these will be added to the new workspace. I'm not sure about this, but it seemed like this the last time I did it. The new workspace and project save path can be placed in the root directory of your project. For example, my project folder is mybiaoke, and I save the two files here. After finishing the work, what should we do if we want to switch projects? We can use the shortcut keys Ctrl+Alt+P and we can switch quickly. For this function, I don’t know if my operation method and steps are scientific, but at least it can be achieved. Please give me some advice from students who know it.
The above introduces the development of PHP with Sublime Text 3, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.
Generated in the HTML code