Git Product home page Git Product logo

vscode-sendtoterminalplus's Introduction

SendToTerminal+, an extension for vscode

VSCode extension that enables sending text selection to the terminal. Can send multiline statements with defined prefix and/or postfix for the selected text so that language REPL can determine that the content will be multiline.

Features

Predefined to allow sending multiline statements with :paste/Ctrl+D to Scala's console or spark-shell.

val s = " some text "
val parts = s.trim()
  .split(" ")

will be send in Scala file as:

  • Prefix:
:paste
  • Selection
val s = " some text "
val parts = s.trim()
  .split(" ")
  • Suffix:
Ctrl+D

demo

If no selection is made then it sends the current line.

Shortcut

Send selection : Alt + Shift + Enter

Extension Settings

Default setting:

    "sendtoterminalplus.languages": [
        {
            "langId": "default",
            "delayMode": "default",
            "payloadFormat": "default",
            "linePattern": "{line}",
            "noSelectionPayload": [
                "{currentline}"
            ],
            "oneLineSelectionPayload": [
                "{selection}"
            ],
            "multiLineSelectionPayload": [
                "{selection}"
            ]
        },
        {
            "langId": "scala",
            "delayMode": "default",
            "payloadFormat": "chunk",
            "linePattern": "{line}",
            "noSelectionPayload": [
                "{currentline}"
            ],
            "oneLineSelectionPayload": [
                "{selection}"
            ],
            "multiLineSelectionPayload": [
                ":paste",
                "{selection}",
                "\u0004"
            ]
        },
        {
            "langId": "python",
            "delayMode": "default",
            "payloadFormat": "chunk",
            "linePattern": "{line}",
            "noSelectionPayload": [
                "{currentline}"
            ],
            "oneLineSelectionPayload": [
                "{selection}"
            ],
            "multiLineSelectionPayload": [
                "{selection}",
                ""
            ]
        }
    ]

Behaviour can be customized per language basis. The language id default is used for all undefined languages.

  • noSelectionPayload: defines what text is going to be send if no text is selected. Default value is ["{currentline}"].
  • oneLineSelectionPayload: defines text sent to the terminal when selected text is only one line. E.g. ["{selection}"] would send one line with the selected text. ["a", "b", "c"] would send three lines with one character per line and not including the selected text at all.
  • multiLineSelectionPayload: defines text sent to the terminal when selected text is more than one line. E.g. [":paste", "{selection}", "\u0004"] would send :paste then selected text and then Ctrl+D key press.
  • linePattern: defines transformation for each line of selected text. Selected text can be decorated on line basis if necessary.
  • payloadFormat: defines what is the format sent to terminal. (values are line, chunk or all). Chunk is block of text defined by length (default setting is 1100 characters). This should circumvent limitation of selected text size sent to terminal on some the environments (e.g. Windows 7, etc...)
  • delayMode: Defines delay period between sending of lines/chunks to terminal. Values are delayed or nodelay. Delay setting is preconfigured to 1500ms. Default value is "nodelay". Connecting to some apps (e.g. sparkshell) via terminal over network requires to have delays sometimes.

Replacement tags to be used in patterns are:

  • {currentline} is text on current line.
  • {selection} is all the selected text.
  • {line} is the text in line. For use in the linePattern only.

Release Notes

1.0.0

0.2.0

  • Added delay, chunk payload format, line processing, noselection pattern.

0.1.0

  • Initial release.

vscode-sendtoterminalplus's People

Contributors

ivoh avatar tokfrans03 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.