KoIDE09 ;; pass selection as input ... is this configurable?


A user can easily add system commands to Komodo, using the powerful runcmd feature.

The setting “pass_selection_as_input” enhances this feature, by allowing pre-selected text to be passed into the command.

This is a great feature, easy to use, and makes Komodo capable of many tasks that would otherwise be difficult to implement.


There may be use-cases where the user wants the command to behave differently, depending on whether there is a current selection or not.

The problem is, this use-case does not appear to be supported directly.

If the user checks the checkbox to “pass_selection_as_input”, the runcmd will not run when there is no current selection, but will instead display an error.


It would be nice if the behavior of this checkbox were configurable.

  • Pass selection as input:
    • If there is no current selection:
      • Do not run the command
      • Pass the current cursorWord to the command and run
      • Pass the current cursorLine to the command and run


Is there a way to change this behavior? or is it instead necessary to file a feature enhancement request for this?


This is what userscripts are for, here is a sample userscript:

var selection = require("ko/editor").getSelection();
if (selection == "")
    selection = "no selection";
selection = selection.replace(/"/g, '\\"'); // sanitize
ko.run.command('echo "' + selection + '"');

Relevant documentation:

1 Like