Most content here "maybe" only applies to Sublime Text 3, please note that Sublime Text 2 was last updated at July 8, 2013
For PHP as well as other languages the plugin that works a lot is CodeIntel, it uses autocomplete as it types, so it does not need any commands. It recognizes functions, classes, and custom namespaces (created in your project), even if it is in a different file.
Install SublimeCodeIntel Preferences > Package Control > Install Package
Type SublimeCodeIntel
, and select it to install
Install PhpIntel Preferences > Package Control > Install Package
Type PhpIntel
, and select it to install
You should now select the folder of your project and drag it to SublimeText, like this:
Nowbythesublimeitself,navigatetotheprojectfiles,openanyfileandpressCtrl+S,CodeIntelwilltakesometimethefirsttime,folderofyourprojectanotherfoldercalled.phpintel
,itcontainsamappingandcachesofyourclasses,everytimeyouuseCtrl+Sitwillupdatethis,justtestitout:
Seethatthenamespaceandclassarenotnative,eventhoughitrecognizesnativePHPaswell.
Othertips
OtherinterestingsettingsyoucantakeintoaccountareeditingtheSettings,gotoPreferences>Settings,itwillopenawindowwithtwodocuments,editonlytheoneontheright,therearesomesettingsyoucanuse:
Removeunnecessaryspaceswhensaving:
"trailing_spaces_trim_on_save": true,
Change TABs by spaces:
"translate_tabs_to_spaces": true,
Use TABs as 4 spaces, you can adjust here:
"tab_size": 4,
Show the encoding of the current file in the SublimeText footer, it helps to avoid many headaches:
"show_encoding": true,
Line breaks use only LF
:
"default_line_ending": "unix",
Show which type of "newline" uses, for example: Unix
(if the rows in the document end in LF
) or Windows
(if the rows in the document end in CR LF
): p>
"show_line_endings": true,
Add line break at the end of the document if necessary (of course this is optional):
"ensure_newline_at_eof_on_save": true,
It should look like this:
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"font_size": 11,
"highlight_line": true,
"ignored_packages":
[
"Vintage"
],
"indent_guide_options":
[
"draw_normal",
"draw_active"
],
"line_padding_bottom": 3,
"line_padding_top": 3,
"overlay_scroll_bars": "enabled",
"show_encoding": true,
"tab_size": 4,
"trailing_spaces_trim_on_save": true,
"translate_tabs_to_spaces": true,
"show_encoding": true,
"show_line_endings": true,
"ensure_newline_at_eof_on_save": true,
"word_wrap": true
}
Extra
Spell checker, has no relation, but a spell checker can help avoid embarrassment sometimes, in case you can manually install it, which can be quite complex, I even tried to download .dic
from LibreOffice and gave it problem with Unicode , so I ended up copying .dic
from the Firefox folder, but this is a bit tricky, so I'll point you to the same repository, select the preferred language in link and download .dic and .aff, for example:
Open the package folder, if it is Linux or Mac:
-
~/.config/sublime-text-3/Packages
If Windows is maybe the folder so SublimeText\Data\Packages\
Create a folder called Portuguese
for example and copy both files to it, you may have to close the sublime and open it again, then go to View > Dictionary and see if Portuguese
appears, or you can point to Settings too, like this:
"dictionary": "Packages/Portuguese/Portuguese (Brazilian).dic",
And enable the spell-checker permanently:
"spell_check": true,
It should look like this:
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"dictionary": "Packages/Portuguese/Portuguese (Brazilian).dic",
"font_size": 11,
"highlight_line": true,
"ignored_packages":
[
"Vintage"
],
"indent_guide_options":
[
"draw_normal",
"draw_active"
],
"line_padding_bottom": 3,
"line_padding_top": 3,
"overlay_scroll_bars": "enabled",
"show_encoding": true,
"spell_check": true,
"tab_size": 4,
"trailing_spaces_trim_on_save": true,
"translate_tabs_to_spaces": true,
"show_encoding": true,
"show_line_endings": true,
"ensure_newline_at_eof_on_save": true,
"word_wrap": true
}