: This article mainly introduces SublimeText3 php Development. if you are interested in the PHP Tutorial, refer to it. It has been four months since the first unpacking hydrology, but it is no longer necessary because of laziness. Finally, today, I think I have written a quasi-technical article.
I forgot how I started using the ST. it should have been used only after I saw someone else's recommendations on the internet. it has been used for half a year. In windows, it is an absolute artifact, and Notepad ++ is incomparable. in linux, it is better to say that, because of vim, the monks do not understand vim. In summary, it is a lightweight text editor for php, python, and other developers. it is very gray and good. we recommend it to you.
I mainly use it to write PHP, which is quite useful. It may also be quite useful in writing python; I don't know what the situation is like when writing ruby, and I have used it for writing. In short, ST is suitable for writing some script languages. for example, C # and Java, we should use traditional and classic IDE.
1. install Sublime Text 3
Official http://www.sublimetext.com/3
Be sure to choose ST3, instead of ST2, 3 is better than 2, really, you will know later.
Select the corresponding version for installation. After completion, you need to install a basic and essential Package management: Package Control, which will be used to install plug-ins later.
Package Control installation
Installation Guide https://sublime.wbond.net/installation
Open ST3 and click View> Show Console. a command input box is displayed at the bottom. copy the preceding command to the input box and press Enter. wait. the installation is successful.
2. plug-in installation
After the Package Control is installed above, we can use the shortcut key Ctrl + Shift + P to open the Package Control to install the plug-in. Enter install in the open input box, and select Install Package as prompted.
Wait, and an input box will pop up asking you to enter the plug-in you want to install.
To install a plug-in that supports UTF8 encoding, you 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, ST supports UTF-8 encoding.
I thought it was a required plug-in
(This is mainly for PHP Development. most of the other languages are commonly used. Please choose one of them)
1. ConvertToUTF8 supports UTF-8 coding plug-ins
2. Bracket Highlighter is used to match brackets, quotation marks, and html tags. It is useful for long codes. After the plug-in is installed, the plug-in will take effect automatically without any configuration.
3. DocBlockr can automatically generate PHPDoc-style comments. The supported languages include Javascript, PHP, ActionScript, CoffeeScript, Java, Objective C, C, and C ++.
4. Emmet (Zen Coding) quickly generates the HTML code snippet plug-in, which is incredibly powerful. if you do not know, google
5. the SideBar Enhancements Plug-In improves the SideBar and adds many features.
6. Themr topic management. when switching a topic, you do not need to modify the configuration file yourself. This allows you to easily switch the topic.
See http://www.ladyloveit.com/sublime/developers-commonly-used-10-sublime-text-plugin
3. general shortcuts
Understanding and mastering the shortcut keys can help you catch up on the fly. so, let's take a look at the useful shortcut keys in ST. here we only talk about what I usually use during development, for complete shortcut key operations, please google.
1. Ctrl + Shift + P
Open Package Control, as described above. There is also a skill, which can be used in various places below, that is, ST supports fuzzy matching. For example, if you want to find the Install Package, you can install it in the Package Control input box. it can automatically match the Install Package, or simply enter an ip address and match it, this fuzzy match function is very convenient.
2. Ctrl + P
Open a file based on the file name. For example, you want to open login/func/funtion. php. you only need to enter login/func/funtion in the input box. php. you can also use fuzzy match, such as login/function. try fuzzy match on your own.
3. what should I do if I want to find the function method after finding the source code file we want to view?
Ctrl + R
Enter log to find all methods with log names. enter loginout to locate loginout ().
You may notice that after Ctrl + R, an @ will automatically exist in the input box, which is the meaning of the matching method. In addition, there are some useful matching symbols.
Locate the row, Ctrl + G, or Ctrl + P, and enter the number of rows in the box, for example, 58, to jump to the 58 rows.
Search for the identifier. after Ctrl + P, # The identifier.
4. after learning the above quick operations, you can basically switch to ST. if you can use ST to write PHP, it is no problem. you can cut and cut all files to quickly jump to the method, it's so nice. But I want to use something better and smoother. I also want to see the following:
Synchronous editing in multiple places, Ctrl + D. This function is frequently used and works well.
When you want to modify multiple identical codes at the same time, for example
$ User ['name'] = 'banaplan ';
$ User ['age'] = 28;
$ User ['desc'] = 'Your younger brother is 28' forever ';
You can double-click the selected user and press Ctrl + D to re-connect to the selected user and repeat it until you are satisfied. then you can edit the user in a unified manner.
---->
Some people have said, cut, what is this? you can use search to replace it. Yes, you can use search to replace it. However, this method is more intuitive and error-free. The so-called, hero sees, each has a different, please refer to the official self-attention.
In fact, in addition to using the Ctrl + D shortcut, you can also use the mouse to achieve the connection. Press Ctrl and double-click to select multiple instances.
In fact, in addition to synchronous editing in the above two methods, there is also a way. That is, Shift, right-click, and vertical drop-down. This method is restricted, that is, it can only be selected vertically. it is applicable to scenarios with a long code segment, as shown below:
5. I feel like this writing is not a waste of writing, but it cannot be so detailed. next I will give you a brief description of the important details that can be found online.
This is common to all of us, but I still want to talk about it.
Ctrl + F, search, the options on the left will not be much said, read the prompt, English, it is difficult to learn English, it seems that now the college entrance examination seems to gradually weaken the weight of English. Note: at the bottom, you will be prompted for the 2 of 5 matches, and a total of 5 matches are found. you are now matching the second one. I think this tips are useful.
Ctrl + F, Enter to find the next, Shift + Enter, and find the previous one.
Ctrl + H, search and replace.
Ctrl + Shift + F. This should be bold and red, so you can point to it. You can call full project search to find the project based on the characters you entered.
As shown above, we can find the file containing have_posts in the wp folder. You may not use them in a few words.
I thought that when I only used NotePad ++ to replace the full-text search without having such a good thing as ST, I wrote a PHP script to implement this function.
---------- I feel tired of writing. it is really hard to do this job. it is not easy to write blogs seriously. There seems to be nothing to elaborate on the remaining shortcut keys. please refer to the online materials ----------
Reference http://ce.sysu.edu.cn/hope/Item/106853.aspx
IV. Advantages of ST
1. PHP code prompt; and existing strings prompt automatically
The lever is easy to use. PHP code prompts automatically and you don't need to explain it. Automatic prompt for existing strings. please refer
$ St_so_powerful is not a built-in PHP variable, but can be automatically prompted because it already exists in the code, so you can prompt for existing characters. This function can greatly save you time coding.
2. code template to quickly generate code
You can click ifelse to quickly generate the if else code template. The key is that PHP code and HTML code generate the corresponding content, which is hard to express in words. please refer
The
I will not explain it. please be enlightened.
Let's talk about the keyword generated by the code in HTML: php echo if ifelse foreach. is it enough?
Not enough ??? Oh, for the custom advanced usage of this code template, google: Sublime Text Snippet
You have to make up for it, or you may have to scold me. Because you did not respond after entering if, press the Tab key, eldest brother.
3. if you are tired of writing, it is over. put a blockbuster function at the end. Please note that this function is only valid in ST3.
Why should I use IDE? Oh, yes, let's first talk about what ide I use, which is a very useful Zend Studio. I only care about its two functions: 1. code jump, jump to a variable or function definition. 2. where is the function referenced (this is a heavyweight killer feature, and I have tried other PHP IDEs ).
Of course, you can't expect our small ST to have this heavyweight killer function, but now ST3 has the first function, namely code jump, which can jump to the function definition. The significance of this function is that you can use ST3 to replace other non-Zend Studio IDEs. :
If the function you want to jump to is defined in only one file, you can directly jump to the past; otherwise, options are provided for you to select the file to jump.
This function does not provide Zend Studio intelligence (Zend directly jumps to the corresponding file), but it is already quite good, isn't it?
Ah, I have to make up for it again. I am so old that my mind is too bad. Forget to jump to the method. select the name of the called function method and click F12. If the F12 shortcut key is in use, modify the default shortcut key to go to the function shortcut key customization, which can be customized to {"keys": ["f3"], "command": "goto_definition"}, because I used to write Java, I have been using Eclipse for some years, so I am used to jump to the function F3, and the reader is self-satisfied. Google
4. although I was tired of writing and publishing, I suddenly remembered that there was another very important feature that I had to say, so I should come back and make up for it.
That is, Add the folder To the Project, click Project> Add Fold To Project, and select the folder you want To Add To the Project.
After you add many folders to a project, you will find a small problem, that is, when Ctrl + P switches the file, the optional list is a bit long, it is because you have many projects, many files with the same name may appear, and the project list on the left does not look fresh. What? You don't see a project list on the left. click View> Side Bar> Show Side Bar.
Therefore, a project occupies a Workspace. if you want to write a project, you can switch to it.
Specific operation: after you add a folder to the Project, click Project> New Workspace For Project to create a Workspace For this separate Project. note, currently, there is only one project. if there are two or more projects, these will be added to the new Workspace. I am not sure about this, however, the last operation seems to be like this. Save the new workspace and project to the root directory of your project. For example, if my project folder is mybiaoke, I will save the two files below.
After that, what should we do if we want to switch the project? use the shortcut key Ctrl + Alt + P to quickly switch over.
For this function, I do not know whether the operation methods and steps are scientific, but at least they can be implemented. please give me some advice.
The above introduces Sublime Text 3 php development, including the content, hope to be helpful to friends interested in PHP tutorials.