jEdit Community - Resources for users of the jEdit Text Editor
use abbreviation for selection
Submitted by sl_ime on Sunday, 4 February, 2007 - 03:57
i have an abbreviation: key: tag abbreviation: <$1>$2$end how would i create a tag that would expand before and after a selection?
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
Re
by sune_simonsen on Wed, 07/02/2007 - 19:05
I'm not exactly sure what you mean, but I think you could use template generation.
You could try something like this:

<#
getTag(s){
  matches = retrieve(s,"^\\w+");
  if(!matches.isEmpty()){
    return matches.get(0);
  } else {
    return "";
  }
}

if(!selection.equals("")) { #>
<${1:tag}>
  <#= selection #>$end
</${1=getTag(s)}><#
} else { #>
<$1><#
} #>

Hope that helped a little

-- Sune Simonsen (SuperAbbrevs)
 
Can do, but no way to invoke the abbrev.
by elberry on Fri, 09/02/2007 - 18:26
You could technically get what ever was selected before the abbrev was invoked using something like this:

[code]
<#
	import org.gjt.sp.jedit.*;
	View view = jEdit.getActiveView();
	Buffer buffer = view.getBuffer();
	EditPane editPane = view.getEditPane();
	JEditTextArea textArea = view.getTextArea();
	String selectedText = textArea.getSelectedText();
#>
<${1:<#= selectedText #>}>$2$end
[/code]

However, once you've selected text there's no way to invoke the abbrev. When you select text and hit tab, the selected text just gets replaced by the tab character. Perhaps this is the intended behavior though?

Eric

Learn from the past. Live in the present. Plan for the future.
 
SuperAbbrevs selection
by sune_simonsen on Sat, 10/02/2007 - 16:58
Hi Eric

In resent version of SuperAbbrevs, there is a menu
Plugins -> SuperAbbrevs -> Show Expansion Dialog.

If you have some selected text and invoke this action, a dialog will pop up.
Type the abbreviation and hit enter. The selected text will be replaced by the abbreviation,
and a variable selection will be available for the template generation, holding the selection. You can then use this variable to insert the selection in the abbreviation. You can see an example of this in my earlier answer.

I'm sorry if I missunderstood what you were trying to point out.

-- Sune Simonsen (SuperAbbrevs)
 
Actually Sir here is a demo f
by sl_ime on Fri, 09/02/2007 - 07:33
Actually Sir here is a demo for that:
Suppose I have the following lines of code:

$select

When I highlight it would it be possible for me to issue an abbreviation on the selection making it i.e.

switch($select){
case 'x':
do_somefunction();
break;
default:
default_funtion();
break;
}

Can it be done?
 
The answer is yes :-) If y
by sune_simonsen on Sat, 10/02/2007 - 17:06
The answer is yes Smiling

If you have $select selected. Invoke the menu
Plugins -> SuperAbbrevs -> Show Expansion Dialog
Then type 'switch' and hit enter.

The switch abbreviation should be something like the following:

switch(${1:<#=selection#>}){
case 'x':
do_somefunction();
break;
default:
default_funtion();
break;
}

This will replace <#=selection#> with $select.

-- Sune Simonsen (SuperAbbrevs)
i mean in superabbrevs..
by sl_ime on Sun, 04/02/2007 - 04:01
i mean in superabbrevs..
 
Take a look at the tags abbrev for html.
by elberry on Tue, 06/02/2007 - 01:09
I don't think there's any easy way to do what you want. Try looking at the tags abbreviation for the html mode.

Learn from the past. Live in the present. Plan for the future.
User login
Browse archives
« October 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
31
 
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   99925
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