EmEditor (text editor) Forum Index
   Questions and Answers about EmEditor Core
     Snippets insertion point
Register To Post

Threaded | Newest First Previous Topic | Next Topic | Bottom
Poster Thread
pja
Posted on: 9/21/2008 6:46 pm
Just popping in
Joined: 2/15/2008
From: Batemans Bay, NSW, Australia
Posts: 20
Snippets insertion point
Hi!
I am writing a number of snippets to try and automate my editing tasks. I would like to be able to insert a snippet and have the cursor positioned in the correct spot to continue typing. For example, a snippet for a HTML blockquote might look like:

<blockquote>
^
</blockquote>

The "^" symbol is where the cursor sits after the snippet has been added. Some editors use place holders like "/^" to achieve this. Is there such a feature in EmEditor? If this is a well known feature then I apologise for wasting people's time, but I have searched extensively.

If I could also add a supplementary question please; where does EmEditor store the snippets? I have looked in the usual places but nothing stands out.

Regards,
Peter


----------------
There is nothing more difficult to take in hand, more perilous to conduct, or more uncertain in its success, than to take the lead in the introduction of a new order of things -- Niccolo Machiavelli, The Prince, ch. 6

Yutaka
Posted on: 9/22/2008 9:15 pm
Webmaster
Joined: 9/28/2006
From: Redmond
Posts: 2398
Re: Snippets insertion point
Quote:

pja wrote:
Hi!
I am writing a number of snippets to try and automate my editing tasks. I would like to be able to insert a snippet and have the cursor positioned in the correct spot to continue typing. For example, a snippet for a HTML blockquote might look like:

<blockquote>
^
</blockquote>

The "^" symbol is where the cursor sits after the snippet has been added. Some editors use place holders like "/^" to achieve this. Is there such a feature in EmEditor? If this is a well known feature then I apologise for wasting people's time, but I have searched extensively.

If I could also add a supplementary question please; where does EmEditor store the snippets? I have looked in the usual places but nothing stands out.

Regards,
Peter


AutoComplete plug-in has the similar feature. I will think about that in the Snippets plug-in as well. Thanks!


----------------
Yutaka Emura
Developer of EmEditor
http://www.emeditor.com/

pja
Posted on: 9/24/2008 12:17 am
Just popping in
Joined: 2/15/2008
From: Batemans Bay, NSW, Australia
Posts: 20
Re: Snippets insertion point
Cheers! That would be most appreciated.

Regards,
Peter


----------------
There is nothing more difficult to take in hand, more perilous to conduct, or more uncertain in its success, than to take the lead in the introduction of a new order of things -- Niccolo Machiavelli, The Prince, ch. 6

Stefan
Posted on: 10/3/2008 8:04 am
Home away from home
Joined: 7/14/2008
From: Germany, EU
Posts: 261
Re: Snippets insertion point
I also would like see this feature in EmEditor.

1.) one symbol in snippet to place the cursor

f.ex.
Snippet: <TD>|||</TD>

If i insert this snippet i would like to have the cursor in place of the three |||

- - - - - - - - - - - -

2.) another symbol to replace the selected text

f.ex.
Snippet: %$§$%

Then i select an word. (or a few lines)
If i insert this snippet i would like to have the selected text enclosed with %-signs (in this example)

- -
An another example for this feature is
Snippet: <b>$§$</b>

Then i select the word 'bold' in this sentence:
This is bold.

And i would get:
This is <b>bold</b>

Would be nice if this would be possible

--
One note:
please choose an sign as replacement placeholder no one would use ever in his code.
Better use an sign combination no one would use to start an sentence like |#| or ] or )
Stefan
Posted on: 7/19/2011 7:48 am
Home away from home
Joined: 7/14/2008
From: Germany, EU
Posts: 261
Re: Snippets insertion point
As an hint for others reading the above request, here is the solution.


To work with selected text have ${SelText} in your snippet.

Example 1:
For HTML; format bold
<B>${SelText}</B>


Example 2:
For AutoHotkey; surround with %-signs
%${SelText}%


- - - - - -


To have your cursor at the right place after the snippet is inserted
simple add an placeholder like $7



Example 1:
For VBScript
Dim $4 As String

Results in:
Dim | As String




Example 2:
For Dairy
${Date} ${Time} Log: "$1"

Results in:
19.07.2011 17:37 Log: "|"




Example 3:
For XYplorer script
$$$1=1; 
  while($$$1 < 10){
     
     msg $$$1,1;
     //your code here> $2
     
     $$$1++;
  }



Usage:
* first, at the first $1, type the name of the loop var, e.g. 'LoOp'
(This var name is copied to all places where the placeholder '$1' is found else)
* second press TAB to jump behind '//your code here'

Note:
the var name for XYplorer script have to be prefixed by an '$'
and since this $ has an special meaning for EmEditor snippet
we have to escape them by doubling this sign to '$$'

Results in:

$LoOp=1;
  while($LoOp < 10){
       
     msg $LoOp,1;
     //your code here>  |
     
     $LoOp++;
  }
Threaded | Newest First Previous Topic | Next Topic | Top


Register To Post
 
English čeština Deutsch español français italiano 日本語 한국어 Русский 简体中文 繁體中文