Re: [code] [textadept] Key Modes

From: Mitchell <>
Date: Tue, 9 Jul 2019 11:43:23 -0400 (EDT)


On Mon, 8 Jul 2019, Qwerky wrote:

> Hello.  Key bindings provide for key modes which, according to the
> documentation, provide a set of key bindings which are executed when that
> mode is active, to the exclusion of all other key bindings.
> Is it possible to have a mode, whose key bindings simply replace the
> same-named bindings while that mode is active, without blocking all other
> bindings[1]?
> An example would be a rectangular-select mode which, when active, would
> replace bindings such as caret-left-extend with
> caret-left-rectangular-extend, and so forth; but would not block other
> bindings, such as caret-left, line-down, etc. This would be extremely useful,
> in the given example, for making selection easier by not having to hold down
> the Alt key, and would also free up Alt key combinations for other functions.
> [1] The mode may also provide new bindings which do not exist outside the
> mode.

Yes, I'm pretty sure this is possible. In your *~/.textadept/init.lua*:

   keys.my_mode = setmetatable({
     esc = function() keys.MODE = nil end, -- exit mode
     -- keys to handle specially go here
   }, {__index = function()
     return false -- propagate everything else

Then set `keys.MODE = 'my_mode'` to initialize it (e.g. via a function bound to a key). Escape key, or whatever else you set, will go back to "normal" mode.


You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Tue 09 Jul 2019 - 11:43:23 EDT

This archive was generated by hypermail 2.2.0 : Wed 10 Jul 2019 - 06:38:41 EDT