SendCode

授权协议 MIT License
开发语言 C/C++
所属分类 应用工具、 终端/远程登录
软件类型 开源软件
地区 不详
投 递 者 相温文
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

SendCode for Sublime Text

Send code and text to macOS and Linux Terminals, iTerm, ConEmu, Cmder, Tmux, Terminus; R (RStudio), Julia, IPython.

Following Programs are supported

  • Mac: Terminal, iTerm (>=2.9), R GUI, RStudio Desktop, RStudio and Jupyter running on Chrome and Safari
  • Windows: Cmder, ConEmu, R GUI, RStudio Desktop
  • Linux: Tmux, Screen, Gnome-Terminal, Pantheon-Terminal, Mate-Terminal, Konsole, RStudio Desktop
  • Sublime Plugin: Terminus

Installation

You could install SendCode via Package Control.

  • If you don't have Package Control installed, follow the installation instructions on the Package Control website.
  • In Sublime Text, type cmd+shift+p (Mac) or ctrl+shift+p (Windows/Linux) to bring up the command palette.
  • Into the command palette start typing Package Control: Install Package and select the option when in pops up.
  • In the Install Package window start typing SendCode and select the option when it pops up.
  • SendCode should then be installed.

If you are using Linux, we might need to installxdotool to use some features. Ubuntu users can use

sudo apt-get install xdotool

If it cannot be found, you will be promptedto download a binary distribution.

Usage

Select a program using the command SendCode: Choose Program in command palette. The default program on macOS, windows and linux are Terminal, Cmder and tmux respectively. Each syntax binds to its own program. For instance, you could bind R to r files and tmux to python files.

There are two main keybindings:

  • cmd+enter (Mac) or ctrl+enter (Windows/Linux)

    If text is selected, it sends the text to the program selected. If no text is selected, then it sends the current block (if found). Finally, it moves the cursor to the next line.

  • cmd+b (Mac) or ctrl+b (Windows/Linux): source current file (R, Julia and Python (IPython) only)

    SendCode uses Sublime build system to source files, you might have to choose the Source File option in a pop up window.

Troubleshooting

  1. Python console

    IPython (5.0 or above, or any repls which support bracketed paste mode) are assumed to be used.

  2. radian console

    You might want to turn on bracketed_paste_mode if radian is used.

  3. RStudio on Windows

    Make sure RStudio v1.1.383 or above is used.

  4. R Gui on Windows

    Make sure the corresponding R program is opened when you are sending the text.

  5. Cmder/ Conemu on Windows

    You might need to set the path to ConEmuC.exe in SendCode settings. For Cmder, the file is located at<path to cmder folder>\\vendor\\conemu-maximus5\\ConEmu\\ConEmuC.exe.

  6. Safari-Jupyter on macOS

    Most likely you haven't enabled JavaScript for AppleScript. Check the option "Allow JavaScript from Apple Events" in the Develop menu (the Develope menu needs to be enabled in the preferences).

Custom Keybindings

It is fairly easy to create your own keybinds for commands which you frequently use. For example, the following keybinds execute changing working directory commands for R, Python and Julia.

[
    {
        "keys": ["ctrl+shift+h"], "command": "send_code",
        "args": {"cmd": "setwd(\"$file_path\")"},
        "context": [
            { "key": "selector", "operator": "equal", "operand": "source.r" }
        ]
    },
    {
        "keys": ["ctrl+shift+h"], "command": "send_code",
        "args": {"cmd": "%cd \"$file_path\""},
        "context": [
            { "key": "selector", "operator": "equal", "operand": "source.python" }
        ]
    },
    {
        "keys": ["ctrl+shift+h"], "command": "send_code",
        "args": {"cmd": "cd(\"$file_path\")"},
        "context": [
            { "key": "selector", "operator": "equal", "operand": "source.julia" }
        ]
    }
]

SendCode expands following variables in the cmd field:

  • $file, the full path to the file
  • $file_path, the directory contains the file
  • $file_name, the file name
  • $file_base_name, the file name without extension
  • $file_extension, the file extension
  • $folder, the first folder of current window
  • $project_path, the directory where sublime-project is stored
  • $current_folder, the folder of the window which contains the current view
  • $selection, the text selected, or the word under cursor
  • $line, the current line number

It also supports placeholders for variables, details can be found in the unofficial documentation.

${file_path:$folder}

This will emit the directory of current file if there is one, otherwise the first folder of the current window.

You also don't have to worry about escaping quotes and backslashes between quotes, SendCode willhandle them for you.

The prog argument determines which program to use

[
    {
        "keys": ["ctrl+shift+enter"], "command": "send_code",
        "args": {"cmd": "\n", "prog": "tmux"}
    }
]

User settings

A couple of settings can be found Preferences: SendCode Settings.Project-wise settings could also be specified in sublime-project as

{
    "settings": {
        "SendCode": {
            "prog": "terminus",
            "r" : {
                "bracketed_paste_mode": true
            }
        }
    }
}

Block expansion

SendCode uses the following logics to expand cursor when sending code.

  • Expand current line to match (), [] and {}.
  • R:
    • backward expand if the previous line ends with a pipe opeartor %>%
    • # %% decorators
    • #+ spin decorators
    • #' roxygen decorators
  • Julia
    • begin, end indented pairs.
    • # %% decorators
  • Python:
    • indentations
    • # %% decorators.
  • (See the settings block_start_pattern and block_end_pattern)
  • Markdown fenced code blocks
    • put the cursor at the line of ``` to send the whole block.
  • Dim mailserver As String mailserver ="test"  Private Function SendEmail(ByVal reportname As String, ByVal MailAddress As String, ByVal filename As String) As Boolean         'Send Email到指定Email Addres

  • import socket import sys import time print 'photoname:' n = sys.stdin.readline() n =n.strip('\n') MCAST_GRP ='224.1.1.1' MCAST_PORT =5007 sock =socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.

  • #coding:utf-8 import sys sys.path.append("lib") import thrift.protocol.TBinaryProtocol as TBinaryProtocol import thrift.transport.THttpClient as THttpClient import evernote.edam.userstore.UserStore as

  • 注意,微信开放平台申请的移动应用: 应用签名:  错误的:CC:2B:D6:D8:45:07:70:89:11:BD:E4:BA:69:57:74:87  正确的:cc2bd6d84507708911bde4ba69577487 包名:com.chinamcr.happybuy 在打包前确认:  1、确认申请时填写的应用签名和安装的应用签名是否一致  2、确认打包时包名、证书别名、私钥密码、证书文

  •         KafkaProducer是Kafka中Producer的一种实现,其主要功能就是发送消息给Kafka中broker。其send()方法如下: /** * Asynchronously send a record to a topic. Equivalent to <code>send(record, null)</code>. * See {@link

相关阅读

相关文章

相关问答

相关文档