sublime插件与使用技巧
html页面的美化,直接ctr+shift+p输入htmlB调用即可。
1.2 JsFormat快捷方式ctr+alt+F,js的格式化。
1.3 SideBarEnhancements增强的侧栏功能,添加就知道怎么好了
1.4 AdvancedNewFile快捷方式ctr+alt+N,New新的文件,支持tab自动补全文件夹,非常方便。
1.5 SyncedSideBar自动同步当前打开文件的side bar位置。
1.6 phpfmt(deleted)直接安装就行。
https://packagecontrol.io/packages/phpfmt
注意确保php在系统的PATH中,因为这个功能具是php写的,需要php执行。
phpfmt已经商业化,需要使用免费的php-cs-fixer.phar作为engine,点击下载php-cs-fixer.phar拷贝到phpfmt的安装目录,更改phpfmt的settings,将engine更改为php-cs-fixer.phar。
另外,在Preferences----Package Settings----phpfmt----Settings - User中添加如下内容
{"autocomplete":true,"autoimport":true,"passes":["AlignEquals","AlignDoubleArrow","AlignDoubleSlashComments","AlignGroupDoubleArrow","LongArray",],"psr2":true,"smart_linebreak_after_curly":true,"version":3}
要执行,直接使用ctrl+shitf+p phpfmt: format now
。或者快捷键ctrl+f11
这个是检查php代码错误的插件,推荐。
安装PHP_CodeSniffer:
pear:下载http://pear.php.net/go-pear.phar执行:phpgo-pear.phar执行:pearinstallPHP_CodeSniffercpi---安装package---->sublimilinter_phpcs1.8 DocBlockr
sublime的php doc插件 DocBlockr,应该大家已经在用,现在需要修改一下配置,避免到处是[description]而实际上没有任何有效的description被添加的情况。
Preferences --> Package Settings --> DocBlockr -> Settings -User:
{"jsdocs_function_description":false,"jsdocs_return_description":false,"jsdocs_param_description":false,"jsdocs_param_name":true,"jsdocs_align_tags":"shallow","jsdocs_spacer_between_sections":true}
一个示例如下:
/***Sendwechatmessageandnoticeforpurchasingorderfinished.**@paramApp\Shop$shop*@paramApp\PurchasingOrder$purchasingOrder**@returnvoid*/
注意
@param
后面有两个空格,而类型后面有一个空格,不需要对齐。
方法说明后一个空行,@param
块后一个空行。@return
后不允许有空行。
这是一个color scheme,关注于把注意力放在代码本身,试用几个周后确实发现这种scheme有其优势。建议大家体验。
1.10 phpcs因为phpfmt商业化导致无法正常使用,使用php-cs-fixer的engine也需要配置很多数据,建议使用phpcs
,配置如下:
使用composer安装php-cs-fixer
composerglobalrequirefriendsofphp/php-cs-fixer
sublime安装phpcs
pci-------------phpcs
配置phpcs,
preferences--packagesettings---phpcodesniffer
将以下内容添加进去:
{//Examplefor://-Windows8.1//-Withphpcsandphp-cs-fixersupport//-Youhavetochange"YOUR_USERNAME_HERE"strings.//-Notice:Thisusesphpcswhichisinstalled//-usingcomposernotxampp.//-Besuretoinstallphpcsusingcomposer.//Wewantdebuggingon"show_debug":true,//Onlyexecutethepluginforphpfiles"extensions_to_execute":["php"],//Donotexecutefortwigfiles"extensions_to_blacklist":["twig.php"],//Executethesnifferonfilesave"phpcs_execute_on_save":true,//Showtheerrorlistaftersave."phpcs_show_errors_on_save":true,//Showtheerrorsinthegutter"phpcs_show_gutter_marks":true,//Showoutlineforerrors"phpcs_outline_for_errors":true,//Showtheerrorsinthestatusbar"phpcs_show_errors_in_status":true,//Showtheerrorsinthequickpanelsoyoucanthengotoline"phpcs_show_quick_panel":true,//Pathtophponwindowsinstallation//Thisisneededaswecannotrunpharsonwindows,sowerunitthroughphp"phpcs_php_prefix_path":"",//Wewantthefixertoberunthroughthephpapplication"phpcs_commands_to_php_prefix":["Fixer"],//PHP_CodeSniffersettings//Yes,runthephpcscommand"phpcs_sniffer_run":true,//Andexecuteitonsave"phpcs_command_on_save":true,//ThisisthepathtothebatfilewhenweinstalledPHP_CodeSniffer"phpcs_executable_path":"C:\\Users\\benjamincao\\AppData\\Roaming\\Composer\\vendor\\bin\\phpcs.bat",//IwanttorunthePSR2standard,andignorewarnings"phpcs_additional_args":{"--standard":"PSR2","-n":""},//PHP-CS-Fixersettings//Don'twanttoautofixissuewithphp-cs-fixer"php_cs_fixer_on_save":true,//Showthequickpanel"php_cs_fixer_show_quick_panel":false,//Thefixerpharfileisstoredhere:"php_cs_fixer_executable_path":"C:\\Users\\benjamincao\\AppData\\Roaming\\Composer\\vendor\\bin\\php-cs-fixer.bat",//Additionalarguments,runalllevelsoffixing"php_cs_fixer_additional_args":{"--level":"psr2","--fixers":"-psr0,array_element_no_space_before_comma,array_element_white_space_after_comma,extra_empty_lines,blankline_after_open_tag,duplicate_semicolon,function_typehint_space,operators_spaces,align_equals,align_double_arrow,ordered_use,whitespacy_lines,concat_with_spaces,unused_use,unary_operators_spaces,ternary_spaces,single_quote"},//PHPLintersettings//Yes,letslintthefiles"phpcs_linter_run":true,//Andexecutethatoneachfilewhensaved(phponlyasperextensions_to_execute)"phpcs_linter_command_on_save":true,//Pathtophp"phpcs_php_path":"C:\\php-7.0.5-nts-Win32-VC14-x64\\php.exe",//Thisistheregexformatoftheerrors"phpcs_linter_regex":"(?P<message>.*)online(?P<line>\\d+)",//PHPMessDetectorsettings//Notturningonthemessdetectorhere"phpmd_run":false,"phpmd_command_on_save":false,"phpmd_executable_path":"","phpmd_additional_args":{"align_equals":""}}
注意:需要将路径配置为自己本地路径。
试一下是否正常。
2. 使用技巧2.1 关于代码折叠:ctrl+shift+[折叠代码块(光标所在位置)ctrlshift]取消折叠(光标所在位置)ctrl+k,0取消所有折叠ctrl+k,1(-9)设置折叠等级:1是类层面,2,就是类的所有函数了。例如如果要将所有函数都折叠,可以这样操作:ctrl+k,2php语法检测,sublime linter-php
打开控制台,install package
搜 sublimelinter
先安装sublimelinter本体
安装完以后再搜索一下,安装sublimelinter-php
接下来,打开preferences-package settings-sublimeLinter-settings--user
如下配置:
{"user":{"linters":{},"paths":{"linux":[],"osx":[],"windows":["D:\\xampp\\php"]},}}
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。