I'm trying to get Sublime Text 3 to work well with Cake's ctp (view) files. The syntax highlighting works fine out-of-the-box, but I can't get the HTML autocomplete to work.
If I open an .html file, I can get the tags and attributes to autocomplete (except in the attribute "style", it doesn't autocomplete CSS styles).
However, if I work on a .ctp file, autocomplete doesn't work at all. I've already tried changing the View->Syntax settings to both PHP and HTML and nothing... I've even tried using the "Open all with current extension as..." with no result.
I've tried using different plugins (ApplySyntax, cakephp plugins, etc) with any success.
Another thing I've noticed, also for javascript code, is that for "short" tags and functions, if I place the cursor at the opening tag or {, the closing tag or } gets automatically highlighted. However, if there's a bunch of lines of code in-between (same language) then the highlight won't happen...
Any help with these things would be really appreciated! I really want to like and use Sublime!
ctp (CakePHP Template). These files contain all the presentational logic needed to get the data it received from the controller in a format that is ready for the audience you're serving to.
ctp files are CakePHP Template Pages, that is view templates. It is used for the view in the MVC that shows output in the browser and act as a view for a controller action. JSON, XML, HTML, JS, CSS, PHP code can be written in it. More than as HTML/PHP pages, it shows data sent from controller.
Just install the ApplySyntax plugin for sublime-text.
ApplySyntax can be installed in a variety of ways:
Through Package Control http://wbond.net/sublime_packages/package_control
Open Package Control Select 'Install Package' Find and select 'ApplySyntax'
By cloning this repository in Packages
cd into your Packages folder
git clone git://github.com/facelessuser/ApplySyntax.git .
By downloading the files and placing them in a directory under Packages, such as ApplySyntax or User
If you don't put the files in Packages/User (you can, but probably shouldn't), make sure they live in Packages/ApplySyntax. If you download and extract a compressed archive from GitHub, the directory will be facelessuser-ApplySyntax
. Remove facelessuser-
.
Courtesy for installation steps: https://github.com/facelessuser/ApplySyntax/blob/master/readme.md
N.B: I installed it and now the *.ctp
files are displayed with proper syntax-highlighting for me.
Update:
In Sublime Text 3, you don't have to use the plugin, you can use the following solution: https://stackoverflow.com/a/35297789/749232
NO NEED FOR A PLUGIN NOW!
In the latest version of SublimeText 3 (at least), you can open a CTP file, then:
View -> Syntax -> Open all current extension as -> PHP
Then just close your open files, and when you re-open them, they'll be highlighted like the language you chose for that extension.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With