> select and write out a particular chunk of code outside to be used elsewhere.

You could use the [context action](https://geany.org/manual/#context-actions) 
with a custom script, but note that this can be set per-filetype as well, in 
which case it's less convenient for this.  You could use a script like so:
<details><summary>Example script, use <code>script.sh "%s"</code> as the 
context action command</summary>
<p>

```shell
#!/bin/sh

# just in case, because it ruins the zenity call if set
unset G_MESSAGES_DEBUG

target="$(zenity --title="Choose a file where to write the selection" 
--file-selection --save --confirm-overwrite)" || exit 1
printf '%s' "$*" > "$target"
```

</p>
</details> 

You can also abuse [*send selection 
to*](https://geany.org/manual/#sending-text-through-custom-commands) for this.  
It's kind of a hack because that feature is used to *transform* the selection, 
but you can still get away with it either by having your script exit with 
failure (then your selection won't be replaced), or have it send out the same 
data it got in, replacing your selection with the same contents.

<details><summary>Example script, use <code>script.sh</code> as the 
command</summary>
<p>

```shell
#!/bin/sh

# just in case, because it ruins the zenity call if set
unset G_MESSAGES_DEBUG

target="$(zenity --title="Choose a file where to write the selection" 
--file-selection --save --confirm-overwrite)" || exit 1
tee "$target"

# and possibly:
#exit 1
```

</p>
You can set custom [keybindings](https://geany.org/manual/#keybindings) for the 
first 9 configured commands.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/issues/3659#issuecomment-1780915819
You are receiving this because you are subscribed to this thread.

Message ID: <geany/geany/issues/3659/[email protected]>

Reply via email to