jEdit Community - Resources for users of the jEdit Text Editor
Different codes
Submitted by Mauro on Tuesday, 15 August, 2006 - 19:19
Hello,
I installed JEdit and found it wonderful.

I easily changed the color code settings for PHP but now I've a little problem.
That is: very often in web pages you have sections with different codes.

In the page I used for testing purposes I have:
- about 20 lines in PHP;
- about 20 lines in JavaScript;
- about 80 lines in (X)HTML;
Now, the three languages are following the "color rules" I set for PHP.

It is possible to have different code colors for these three languages in the same .php page? Please, tell me it is... Smiling and possibly how...

Thanks very much.
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
use macro & keyboard shortcuts to switch modes
by paulflory on Sun, 20/08/2006 - 03:43
Not sure if there's a way to have jEdit syntax-color and parse multiple languages at the same time. Distinguising between them seems like an intersting problem.

A somewhat cheap solution is to setup a macro and some keyboard shortcuts that toggles between 2 or more buffer modes (e.g., xml, perl, js).

Here's some sample macro code (not sure where this came from):
// ToggleEditMode.bsh - bind to a key
final Mode[] MODES = {jEdit.getMode("perl"), jEdit.getMode("xml") };
int newMode = 1; // xml index

Mode curMode = buffer.getMode();
for (int i = 0; i < MODES.length; i++) {
	if (curMode == MODES[i]) {
		newMode = (i + 1) % MODES.length;
		break;
	}
}
buffer.setMode(MODES[newMode]);
view.getStatus().setMessageAndClear("Edit mode: " + buffer.getMode().toString());

Well, I know that's not exact
by cvicari on Thu, 17/08/2006 - 10:14
Well, I know that's not exactly what you're looking for... but I saw, from the html edit mode, that you can do like this:

<!-- JavaScript -->
<SPAN TYPE="MARKUP" DELEGATE="JAVASCRIPT">
<BEGIN>&lt;SCRIPT</BEGIN>
<END>&lt;/SCRIPT&gt;</END>
</SPAN>

thus allowing html to delegate a portion of the file to another edit mode... You could write your own, specifying some special tag that activates a specific edit mode, I think it's quite easy.
 
Interesting, thanks. :-)
by Mauro on Sat, 19/08/2006 - 13:17
Interesting, thanks. Smiling
User login
Browse archives
« September 2024  
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   97301
Context Free Art (*.cfdg)   0.31   46061
BBEdit scheme   1.0   18600
JBuilder scheme   .001   18501
ColdFusion scheme   1.0   18030
R Edit Mode - extensive version   0.1   17480
Advanced HTML edit mode   1.0   16212
Matlab Edit Mode   1.0   16074
jEdit XP icons   1.0   15235
XP icons for jEdit   1.1   14299