Editing php code easily and with proper indentation
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Editing php code easily and with proper indentation
Hi,
My editor of choice is emacs (the version I got with Red Hat 9.0 which has a number of features that make it more like xemacs that I had when I ran SuSE 7.2 - maybe it is xemacs). The auto-indentation works great with C code, but is simply wrong when I edit php script. After the 1st 'if' statement, the indentation remains. For the subsequent few 'if's and 'foreach's the code that should be further indented isn't.
I have downloaded and installed php-mode 1.2.0 from SourceForge to no avail. Same problem.
I set the "TAB" key to self-insert-command to try to do my own indentation. But emacs would still auto-indent (wrongly) on typing characters like '('.
The only way I could stop emacs from auto-indenting was to remove php-mode altogether. This is not what I want as I want the syntax highlighting. In fact, I want auto-indenting because manually indenting can be so time-consuming, especially if you change the structure of your code. I just want it to work properly.
I resorted to vi. However, as well as having to manually indent, moving between buffers in vi is not nearly as quick and convenient as with emacs.
Does anyone know of an emacs lisp file for php mode that works properly, or another good editor.
Further to my original message, I've found that the auto-indent works fine for function definitions. It's the code that's outside of any function that's not indenting properly.
I've found that PHP code that is outside of any function can be enclosed by a pair of braces. The script runs the same, but the emacs editor will indent properly between a pair of braces, while it will not properly indent code that is not between braces.
Thanks for the info on alternative editors available.
Now that I've found the work-around of enclosing the code in braces I'll get on with what I know for now and maybe re-visit the idea of switching software if another issue comes up.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.