如何在Sublime Text 2编辑器中将行传递到控制台 [英] How to pass a line to the console in sublime text 2 editor

查看:97
本文介绍了如何在Sublime Text 2编辑器中将行传递到控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用RStudio处理R编程语言,并找到ctrl+enter快捷方式将行发送到控制台,这对于解决我的工作非常有用.

I use RStudio for working with R programming language and find the ctrl+enter shortcut to send a line to the console extremely useful in troubleshooting my work.

现在我正在使用sublimetext2,我想在RStudio中做同样的事情,向控制台发送一行.

Now I am using sublimetext2 and I would like to do the same thing in RStudio, send a line to the console.

是否可以将现有线路发送到控制台或SublimeREPL控制台?

Is there a way to send the existing line to the console or a SublimeREPL console?

推荐答案

我不知道控制台,但是可以通过 SublimeREPL .

I don't know about the console, but this is possible with SublimeREPL.

只要您同时打开一个REPL和使用相同语言的文件,就可以通过SublimeREPL

As long as you have a REPL and a file of the same language open at the same time, you can send a line (or a selection or file) to your open REPL via the SublimeREPL Source Buffer Keys. By default, Ctrl+, followed by l sends the current line to the REPL, but you can change the hotkey to Ctrl+Enter (in Python only, to protect other languages' default Ctrl+Enter functionality) by adding these lines to the top of your Preferences -> Key Bindings – User file:

{ "keys": ["ctrl+enter"], "command": "repl_transfer_current", "args": {"scope": "lines"}, "context":
    [
        { "key": "selector", "operator": "equal", "operand": "source.python", "match_all": true }
    ]
},

(Preferences -> Browse Packages -> SublimeREPL/Default (Windows).sublime-keymap中的)其他可用范围是selectionfileblock(仅适用于Clojure).如果要向REPL发送一条线但立即对其进行解析,则可以将"action":"view_write"添加到args对象,如下所示:

Other available scopes (from Preferences -> Browse Packages -> SublimeREPL/Default (Windows).sublime-keymap) are selection, file, and block (Clojure only). If you want to send a line to your REPL but not parse it immediately, you can add "action":"view_write" to the args object, like so:

{ "keys": ["ctrl+enter"], "command": "repl_transfer_current", "args": {"scope": "lines", "action": "view_write"}, "context":
    [
        { "key": "selector", "operator": "equal", "operand": "source.python", "match_all": true }
    ]
},

请参见非官方Sublime Text 2文档有关键绑定的更多信息.

See the Unofficial Sublime Text 2 Docs for more information on key bindings.

如果REPL在与源不同的选项卡中打开(而不是在单独的视图中),则源缓冲区热键将聚焦于REPL.我确信可以实现某种选项卡交换的切换键,但这听起来像是另一个问题的问题.

In the case that the REPL is open in a different tab than your source (rather than a separate view), the source buffer hotkeys will not focus the REPL. I'm sure it's possible to implement some sort of tab-swapping toggle key, but that sounds like a problem for another question.

这篇关于如何在Sublime Text 2编辑器中将行传递到控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆