Reply to topic

Looking for editor that supports PHP indentation

User avatar ethereal1m
Registered Member
Posts
81
Karma
0
OS
Dear all,
Is there any editor in KDE that supports PHP indentation or at least something that its indentation can be easily configured? I search through the web and found that Kate indentation can be configured, but it requires kateautoindent.h and kateautoindent.cpp modification, which I can't find those files in my KDE version (4.3.1).

Any suggestion?

regards,
ethereal1m
john_hudson
Registered Member
Posts
549
Karma
2
OS
Doesn't Configure Kate>Editing>Indentation meet your needs? Also, I'm not sure what standard PHP supports but there are several styles already built in - though not PHP.


John Hudson, proud to be a member of KDE forums since 2008-Oct.
User avatar ethereal1m
Registered Member
Posts
81
Karma
0
OS
unfortunately it doesn't do anything when I select all and do Kate>Editing>Indentation. I want to do transform the following:
Code: Select all
function some_funct() {
if (a==1) {
b=2;
}
}

into:
Code: Select all
function some_funct() {
  if (a==1) {
    b=2;
  }
}


How can I make it with Kate?
thanks
john_hudson
Registered Member
Posts
549
Karma
2
OS
I don't think it will indent existing files; it simply puts in the correct indentation in a new file.


John Hudson, proud to be a member of KDE forums since 2008-Oct.
airdrik
Registered Member
Posts
1691
Karma
3
OS
The indentation mode only changes what happens when you hit enter to start a new line (intended for the purpose of reducing the necessity to hit tab several times after starting a new line). I don't know of any non-IDE editor that will format existing code for you (i.e. add indentation to existing code according to predetermined rules), though there are some that do support switching between tabs and spaces if the indentation is already there. You may be able to write a script that will handle adding indentation to your code, which you could add as an external tool to the editor.


airdrik, proud to be a member of KDE forums since 2008-Dec.
User avatar Hans
Administrator
Posts
3304
Karma
23
OS
airdrik wrote:I don't know of any non-IDE editor that will format existing code for you (i.e. add indentation to existing code according to predetermined rules)


Vim can do it, but maybe you meant KDE editors (which I haven't used much).
Code: Select all
vim /path/to/file.php
gg=G
:wq


This will open /path/to/file.php in Vim, autoindent the entire file, save the file and quit.

As airdrik mentions there should be external tools (scripts etc.) to autoident file, although I don't know the name of any.


Problem solved? Please click on "Accept this answer" below the post with the best answer to mark your topic as solved.

10 things you might want to do in KDE | Open menu with Super key | Mouse shortcuts
airdrik
Registered Member
Posts
1691
Karma
3
OS
Hans wrote:
airdrik wrote:I don't know of any non-IDE editor that will format existing code for you (i.e. add indentation to existing code according to predetermined rules)


Vim can do it, but maybe you meant KDE editors (which I haven't used much).
Code: Select all
vim /path/to/file.php
gg=G
:wq


This will open /path/to/file.php in Vim, autoindent the entire file, save the file and quit.


Vim is practically an IDE of its own (besides that I've never really used vim, so I am not familiar with any of its features). By non-IDE code editor, I'm referring to most other code editors that I've used e.g. Kate, Gedit, Notepad++, Programmer's Notepad, Editra, Komodo edit, etc. I've used about a dozen different ones over the last couple of years and I don't remember any that would format existing code (except maybe XML and HTML). That's a feature that generally falls just outside of the scope of what they are designed to do.


airdrik, proud to be a member of KDE forums since 2008-Dec.
User avatar ethereal1m
Registered Member
Posts
81
Karma
0
OS
notepad++ does that automated indentation.....go to TextFx -> Reindent C++ code
airdrik
Registered Member
Posts
1691
Karma
3
OS
Well I stand partially corrected - that's an exceptional case as the re-indenting is handled via a plugin (that's installed by default), though it only handles c++ code.

I agree that it would be nice to have a plugin/external tool for kate/kdevelop for reformatting code (adjusting white-space) according to configurable rules (with a selection of presets for various languages' coding conventions).


airdrik, proud to be a member of KDE forums since 2008-Dec.
Burgman650
Registered Member
Posts
1
Karma
0
Try Nuesphere - used it for years
User avatar neverendingo
Administrator
Posts
2136
Karma
17
OS
You can indeed intend functions afterwards in Kate.
First set your prefered intendation method via "extras -> intendation", then mark the parts you want to have intended and then "extras -> adjust" (or align, having a localized version here)
C-Style worked best for me, but you can test the others.


New to KDE Software? - get help from Userbase or ask questions on the Forums
Communicate.
Image

 
Reply to topic

Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], JesseWebb, kyrhammer, Majestic-12 [Bot], Yahoo [Bot]