Github

As software developers, we spend most of our time staring down at code until the bug feels uncomfortable and reveals itself so we can sorta fix it; or we write fabulous code that we’ll be ashamed of after a while. Regardless of the day & it’s productiveness, we bởi vì spkết thúc most of the time in our IDEs or Text Editors. I chose to lớn spkết thúc it in Sublime Text.

Bạn đang xem: Github

I’ve sầu used different IDEs in my life spanning from NetBeans, to lớn Eclipse, Visual Studio, và others, và it is always good khổng lồ have something pointing out your errors before even trying out the solution, but for me, IDEs felt too slow và somewhat laggy.

When it comes khổng lồ coding with a text editor, the choice is wide but it can be narrowed lớn the most popular ones: Vim, Notepad++, Atom, and Sublime Text.

I gave Notepad++ a chance some time ago but it didn"t get to lớn me; with Vlặng, my biggest achievement is“knowing how to quit!”; Atom I still haven"t tried, but a colleague of mine is very satisfied with it.

In this article, I want to show you why I chose Sublime Text and how I made it work for me.

TL;DR;

Let’s start with the quichồng thiết đặt.

Install Sublime TextInstall it.Profit.

Once you’ve sầu installed the basic text editor you should already have sầu a wide range of options available, from creating snippets of code, to lớn shortcut customisations and protệp tin settings.

This is a fair enough start và you will feel comfortable using it as is, but there are improvements khổng lồ be made.

Sublime Text relies on packages khổng lồ extend its functionality. When the packages are chosen & configured wisely it becomes more lượt thích an IDE without the laggy side, but also without the pre-compile error catching.

Package control

To be able lớn install packages easily you will need the so-called Package Control. To install it follow the instructions here.

Once installed, you should be able lớn prompt a panelby pressing ctrl+shift+p on Linux & Windows, và cmd+shift+p on OS X.



We’ll use this panel khổng lồ install all of the other packages.

The next section is about speeding up code writing using plugins like Emmet.

Emmet

To install Emmet prompt the panel as mentioned above sầu by pressing ctrl+shift+p & type Install Package. The first thành tích in the danh mục is the Package Control: Install Package. Cliông chồng on it, wait for a second or so & a new panel will appear. Type Emmetthere and then select the first one.

Congratulations! But what did you just install?

Emmet is a compilation of shortcuts and snippets that allows you for quick writing of HTML và CSS code.

For example:

In an HTML document, type ! andpress tab. This will generate a whole HTML5 boilerplate. Or, try ul>li*5>a.nav & hit tab. This one generates a danh sách with 5 elements, each containing a link with class nav.

You can install extensions of emmet if you like, khổng lồ include more snippets or shortcuts. To vì chưng so, repeat the procedure to lớn Install Package, write Emmet in the new prompt và see what is available there. If there is something that may suit you, go ahead and install it.

PHP Companion (PHP. Developers Only)

Again, start with the familiar ctrl+shift+p combination & Install Package, then tìm kiếm for PHP. Companion. Great. Now that it’s installed, go to Preferences -> Key Bindings. This will show you two files, the one on the left should be full of mặc định settings, those are Sublime Default Key Bindings. On the right, you’ll see the User Specific Key Bindings.

This is an example of how you can cài đặt your custom commands. Cheông xã this for more details.

Xem thêm: Mô Hình Ogsm Là Gì ? (Đây Là Mô (Đây Là Mô

< "keys": <"f6">, "command": "expand_fqcn" , "keys": <"shift+f6">, "command": "expand_fqcn", "args": "leading_separator": true , "keys": <"f5">, "command": "find_use" , "keys": <"f4">, "command": "import_namespace" , "keys": <"f3">, "command": "implement" , "keys": <"shift+f12">, "command": "goto_definition_scope" , "keys": <"f7">, "command": "insert_php_constructor_property" >Paste that code in your User Specific tệp tin (file on the right). Save sầu the changes, then restart Sublime Text editor.

What PHPhường Companion does, is using shortcuts lượt thích f5 & f6 lớn find the namespace of a class & automatically inline it (f5) or import it at the top of the file (f6).

For OOP. & developing with frameworks that rely on classes & namespaces, PHP.. Companion is a huge boost in productivity.

Beauty of Code

"Any fool can write code that a computer can understvà. Good programmers write code that humans can understand." - Martin Fowler, 2008.

Taking the above quote for what it is, truth in all & per all, we need khổng lồ write good, well formatted, readable, và understandable code. After all, the only real measure of the code chất lượng is the WTF per Minute.

That said, let’s jump on the packages that will make this easier.

DocBlockr

This plugin is a straightforward one. After installing you can go to lớn any file,type /**, và then quickly hit Tab.

This should generate a blochồng comment section lượt thích the one below.

/** * *
return */As you can see, it automatically populates the parameter names và types (if detectable) và the return type of the function.

Documentation is number one for writing good code and this plugin makes it much easier to lớn handle.

Alignment

Suppose you have sầu the following code:

$táo khuyết = “apple”;$pear = “pear”;$banamãng cầu = “banana”;You can highlight them all at once, press ctrl+alt+a and what you’ll get is:

$táo khuyết = "apple";$pear = "pear";$banamãng cầu = "banana";This is especially useful when you have sầu huge arrays containing many single key => value pairs and you want khổng lồ make it easy lớn read/edit.

Code Correction

Keeping in mind that Sublime text is not an IDE, helpful hints lượt thích syntax errors for custom classes or variables are not easily available. That said, we can still have helpers that let us know if a semicolon is missing or parenthesis has not been closed or similar issues before we open the browser to lớn thử nghiệm it ourselves.

Sublime Linter

Sublime Linter is a basic package that provides syntax error checking out of the box, for Pyhạn hẹp, JS, CSS, & Ruby.

Once installed it should work right away. Try it yourself: open a .js file, make a syntax error & you should be able to lớn see a red dot on the left side near the line number.


*

For the languages that are not automatically available with Sublime Linter, all we need khổng lồ vị is install additional packages by prompting the panel once again.Doctrl+shift+p, type Install Package and, finally,Sublime Linter, then select the language of choice like PHP for example.

Hope you found this article helpful! Do you have sầu some favorite packages that make your coding life easier? Share it in the comments below.

Hiring Dedicated PHPhường Developers? Cheông xã out our PHPhường. Developers Community.


Sublime Text can be downloaded và installed for không tính phí, but a license should be purchased for continued use. There is no enforced time limit for the evaluation.
There is no legal requirement khổng lồ buy Sublime. You can use the unlimited evaluation period, but a licence must be purchased for continued use.