Re: [code] [textadept] Is there a way to enclose text in Snippets?

From: cryo shock <>
Date: Thu, 23 Mar 2017 19:09:02 +0100

Guten Tag Robert ;),

thanks for your answer. That's absolutely what I was looking for.
I can't explain to myself, how I could over-read this. Since English isn't
my native language I assume that I simply didn't know how to translate what
I was looking for. On the other hand I have no experience in programming,
Lua not to mention, yet, I have to say that in the API manual it isn't
explained as easily as you did.

To put it short:
I already had snippets added to my user/init.lua and they look like this:

snippets.context['emph'] = '{\\em %0}' -- emphasize text

With your help I only had to add the string you mentioned: <selected_text>
after the %n placeholder. Now the snippets look like this:

snippets.context['emph'] = '{\\em %0<selected_text>}' -- emphasize text

Of course it works, so thanks again. Before, I also added the "Insert
Snippet..." menu to my right-click context menu. Now I can highlight text
and surround it with a nippet just by using the mouse, which makes
Textadept my favorite editor.

Now that we've already begun, may I ask another question? I would like to
add documentation to the snippets. I assume that simply putting a third
dash before "-- emphasize text that is highlighted" won't do the trick.
When you comment the documentation with -- or --- then the text doesn't pop
up in the snippet menu (what I totally agree with). But what I imagine is:
When you open the snippet context menu, you have a third section after
"Trigger" and "Snippet Text" like "Comment" or "Documentation".

Is this somehow achievable without using additional software?

Cheers, Sebastian

2017-03-23 7:53 GMT+01:00 Robert Gieseke <>:

> Hi,
> something like:
> = [[\bf{ %0<selected_text> }]]
> The `selected_text` variable contains the originally selected text.
> Cheers,
> Robert
> Am 23/03/17 um 00:46 schrieb cryo shock:
> > Hi there,
> >
> > I read in the manual about how to enclose text in brackets and so on,
> > can be also found out when using Edit...
> >
> > Yet I haven't found a way so far, to enclose a highlighted text in
> > snippets. I think it's possible to add them like in the Edit menu for
> > each command, but is there also a way to open the snippet context menu
> > on a highlighted text?
> >
> > Right now when you open the snippet menu and chose one then the
> > highlighted text gets overwritten. It would be great, if I could use the
> > snippet context menu like this:
> >
> > you have a text "Word", you highlight it, you press Ctrl+K or similar,
> > then choose a snippet like italic or bold, and then the text looks like
> > this: {\bf Word}
> >
> > Thank you very much in advance for every help.
> --
> You are subscribed to
> To change subscription settings, send an e-mail to
> To unsubscribe, send an e-mail to

You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Thu 23 Mar 2017 - 14:09:02 EDT

This archive was generated by hypermail 2.2.0 : Fri 24 Mar 2017 - 06:54:11 EDT