Skip to content

Command that takes the current word or selection and sends it as an arg #201

Closed

Description

@andycraig

Another idea I had is a variant of this that take the current word or selection and sends it as an arg.

Would enable stuff like:

[
  {
    "description": "loadd target under cursor",
    "key": "ctrl+l",
    "command": "r.somethingSomethingWithSelectionOrWord",
    "when": "editorTextFocus && editorLangId == 'r'",
    "args": "drake::loadd"
  }

Thoughts on that one?

Originally posted by @MilesMcBain in #199 (comment)

Activity

  1. andycraig commented on Jan 24, 2020

    @andycraig
    CollaboratorAuthor

    There's a function runSelectionOrWord that if called with runSelectionOrWord(["t", "head"])) will send t(head(SELECTION)) to the console. It sounds like that would do the job if it were exposed in package.json.

    I've been thinking of changing it so you'd call it like with 'before selection' and 'after selection' arguments: runSelectionOrWord("t(head(", "))"). That would enable more control, such as quoting the selection or passing it to a named parameter. Knitting the selection could then be done as discussed here: #155 (comment)

    EDIT: Fixed order of functions

  2. andycraig commented on Apr 16, 2020

    @andycraig
    CollaboratorAuthor

    Closed by #237. Thanks again @MilesMcBain!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions