jEdit Community - Resources for users of the jEdit Text Editor
Unindend by backspace
Submitted by Anonymous on Monday, 21 February, 2005 - 21:14
"Backspace unindents" is the last one feature I miss from jEdit, after we got back wrapping text at window edge in 4.3pre1. jEdit is great, but this feature is the one, that makes me still using Delphi and Eclipse -- their editors all can unindent by backspace. Please?!
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
If I understand what you're a
by Anonymous on Tue, 22/02/2005 - 13:44
If I understand what you're asking for, try assigning Macros > Editing > Greedy Backspace to BACK_SPACE. It only behaves differently if using soft tabs (spaces instead of tabs).

-Ollie
 
Soft tabs are the key here
by Anonymous on Wed, 23/02/2005 - 11:36
That's why I call this "unindent" not "delete last character". I mean: "if at position before first non-whitespace character, shift indent right one level for current line, regardless of tab settings".
 
If by 'right' you mean 'left'
by Anonymous on Wed, 23/02/2005 - 20:12
If by 'right' you mean 'left', try saving the following as a macro and assigning it to BACK_SPACE. I believe it will do you're looking for.
void backspaceOrUnindent()
{
	if(buffer.isReadOnly())
	{
		Toolkit.getDefaultToolkit().beep();
		return;
	}

	int line = textArea.getCaretLine();
	int lineStart = textArea.getLineStartOffset(line);
	int caret = textArea.getCaretPosition();

	// if at line start or linestart + 1, backspace as normal
	if(lineStart+1 >= caret)
	{
		textArea.backspace();
		return;
	}

	char[] text = buffer.getText(lineStart,(caret-lineStart)-1).toCharArray();

	// Check that we've only got whitespace.
	// If any non-whitespace found, backspace as normal.
	for(int i=0; i < text.length; i++)
	{
		if(text[i] != ' ' && text[i] != '\t')
		{
			textArea.backspace();
			return;
		}
	}

	textArea.shiftIndentLeft();
}

backspaceOrUnindent();
 
If by 'right' you mean 'left'
by Anonymous on Tue, 22/03/2005 - 11:39
Yes, that's it, thank you.
But still, while it works, I think it should be editor feature, not a macro.
 
I'm not sure I agree with you
by Anonymous on Thu, 24/03/2005 - 14:48
I'm not sure I agree with you on that. That "feature" would drive me insane.
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