jEdit Community - Resources for users of the jEdit Text Editor
Jedit 4.3pre16: automatic identation in C++ mode witchin switch/case blocks
Submitted by SegFault on Monday, 23 February, 2009 - 16:02
Hello. I'm using jedit 4.3pre16 on slackware 12.2 linux, and I had following problem: When I was typing something something like -- switch(index){ case(Choices::done): -- jedit kept moving (case(Choices::done)Smiling line to the left (i.e. was unindenting the line) every time I typed colon (*any* colon - even the one in the middle of Choices::done). I was able to partially fix it by copying cplusplus.xml to ~/.jedit/modes, adding it to ~/.jedit/modes/catalog and replacing --- ?!Smiling).*$" /> --- with --- ?!Smiling).*$" /> --- But I got another problem. Now when I type something like: --- switch(index){ case(Choices::done): break; case(Choices::cancel):{ --- jedit keeps moving "case(Choices::cancel):{" to the right (i.e. indenting) when I type "{". This obviously happens because jedit "thinks" that break is not within indentation block and defines proper indentation level. How can I fix that? I've tried replacing --- --- with regexp that would exclude "case" (something like "(?!\bcase\b.*\(.*\):){"), but this didn't work (it looks like indentOpenBrackets doesn't take regexp as argument). Any ideas?
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
No reply within 7 days. Quest
by SegFault on Sun, 01/03/2009 - 22:49
No reply within 7 days. Question abandoned.
Damn it. Preview didn't work
by SegFault on Mon, 23/02/2009 - 16:15
Damn it.

Preview didn't work & now formatting is messed up.

Posting it again.

I'm using jedit 4.3pre16 on slackware 12.2 linux, and I had following problem:

When I was typing something something like

switch(index){
	case(Choices::done):
jedit kept moving
(case(Choices::done)Smiling
line to the left (i.e. was unindenting the line) every time I typed colon (*any* colon - even the one in the middle of Choices::done). I was able to partially fix it by copying cplusplus.xml to ~/.jedit/modes, adding it to ~/.jedit/modes/catalog and replacing
        <PROPERTY NAME="indentNextLine"
            VALUE="(?!^\s*(#|//)).*(\b(if|while|for)\s*\(.*\)|\b(else|do)\b)[^{;]*$" />
        <PROPERTY NAME="unindentThisLine"
            VALUE="^\s*((.*case\b.*|[\p{Alpha}_][\p{Alnum}_]*)\s*(slots)?Sad?!Smiling).*$" />
with
        <PROPERTY NAME="indentNextLine"
            VALUE="(?!^\s*(#|//)).*(\b(if|while|for)\s*\(.*\)|\b(else|do)\b|\bcase\b.*\(.*\))[^{;]*$" />
        <PROPERTY NAME="unindentThisLine"
            VALUE="^\s*(([\p{Alpha}_][\p{Alnum}_]*)\s*(slots)?Sad?!Smiling).*$" />
But I got another problem. Now when I type something like:
switch(index){
	case(Choices::done):
		break;
	case(Choices::cancel):{
jedit keeps moving "case(Choices::cancel):{" to the right (i.e. indenting) when I type "{" or colon. This obviously happens because jedit "thinks" that break is not within indentation block and defines proper indentation level. How can I fix that? I've tried replacing
        <PROPERTY NAME="indentOpenBrackets" VALUE="{" />
with regexp that would exclude "case" (something like "(?!\bcase\b.*\(.*\):){"), but this didn't work (it looks like indentOpenBrackets doesn't take regexp as argument). Any ideas?

P.S. This forum should have option to disable smileys.

User login
Browse archives
« November 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   101634
Context Free Art (*.cfdg)   0.31   46062
BBEdit scheme   1.0   18601
JBuilder scheme   .001   18502
ColdFusion scheme   1.0   18031
R Edit Mode - extensive version   0.1   17481
Advanced HTML edit mode   1.0   16213
Matlab Edit Mode   1.0   16075
jEdit XP icons   1.0   15236
XP icons for jEdit   1.1   14300