Re: [code] Parenthesis and selection

From: Mitchell <m.att.foicica.com>
Date: Wed, 28 Sep 2016 11:07:02 -0400 (EDT)

Hi Pedro,

On Wed, 28 Sep 2016, Pedro Andres Aranda Gutierrez wrote:

> Hi,
>
> I was wondering how to make Textadept put parenthesis around the selection
> when I'm in Latex mode (for example). When I have a word and I want to put
> it in italics, it's like
>
> \textit{word}
>
> If I'm modifying an exisiting document, the easiest way would be to write
> '\textit' before it, then select the zone I want on italics and then just
> press '{' to put the selection between {}
>
> Currently, pressing { will replace the selection with {}...

The function you want is `textadept.editing.enclose()`[1]. Then you'll
want to override the '{' key. Something like this in your
`~/.textadept/init.lua` will work:

   keys['{'] = function()
     if buffer.selection_empty then return false end -- default { insert
     textadept.editing.enclose('{', '}')
     return true -- prevent default { insert
   end

Cheers,
Mitchell

[1]: http://foicica.com/textadept/api.html#textadept.editing.enclose

-- 
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 Wed 28 Sep 2016 - 11:07:02 EDT

This archive was generated by hypermail 2.2.0 : Thu 29 Sep 2016 - 06:25:37 EDT