Re: [code] Storing commands

From: Mitchell <m.att.foicica.com>
Date: Thu, 5 Mar 2020 15:00:01 -0500 (EST)

Hi Juh,

On Thu, 5 Mar 2020, juh wrote:

> Am 05.03.20 um 14:41 schrieb Mitchell:
>> Hi Juh,
>>
>> On Thu, 5 Mar 2020, juh wrote:
>>
>>> Hi all,
>>>
>>> sometimes I use the pipe command function to reformat the text in
>>> different ways, eg.
>>>
>>> awk '{gsub(/\. /,".\n");print}'
>>>
>>> sed -e 's/\.  */.\n/g' -e 's/\.$/.\n/g'
>>>
>>>
>>> As I can't memorize these commands I am looking for a way to store them
>>> anywhere, something like a "macro" for so.
>>
>> You can use a keybinding defined in your *~/.textadept/init.lua*:
>>
>>   keys.something = function()
>>     textadept.editing.filter_through("awk '{...}'")
>>   end
>
> Thanks a lot.
>
> I get an error message with this:
>
> keys.cQ = function()
> textadept.editing.filter_through("awk '{gsub(/\. /,".\n");print}'")
> end
>
> invalid escape sequence
>
> How can I correctly escape things. Sorry, I am new to Lua.

You can do one of two things: \" or wrap your string in [[ ]] to avoid escapes.

   textadept.editing.filter_through("awk '{gsub(/\. /,\".\n\");print}'")

   textadept.editing.filter_through([[awk '{gsub(/\. /,".\n");print}']])

Cheers,
Mitchell

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Thu 05 Mar 2020 - 15:00:01 EST

This archive was generated by hypermail 2.2.0 : Fri 06 Mar 2020 - 06:53:11 EST