Keyboard shortcut to switch between the code editor and ipython console using the Canopy - canopy

How can I create a keyboard shortcut to switch between the code editor and ipython console using the Canopy IDE?
I have tried writing a macro according to the documentation for code editing (http://docs.enthought.com/canopy/configure/editor-scripting-api.html#code-editor-scripting-commands) and the ipython pane scripting commands (http://docs.enthought.com/canopy/configure/ipython-scripting-api.html#ipython-pane-scripting-commands, but do not see a solution.
As an example, I have a macro that will execute the current line of code (without having to select it), but it would be nice to be able to switch the cursor back to the code editor after execution without touching the mouse/trackpad.
def run():
code_task = get_active_task()
code_editor = code_task.active_editor
cursor = code_editor.cursor
cursor.start_of_line()
cursor.next_line(select=True)
code_task.run_selection()
Using Canopy Version: 1.1.1 (64 bit) on Mac OS X 10.7.5

Thanks, great suggestion. Added to Canopy wish list. (You can use the keyboard shortcut Control+Tab to cycle among File Browser, Editor, and IPython, but this is not yet macro-able.)

(on Mac) -> Better Touch Tool. This is a macro that is only active while i'm in emacs, which does the following:
save the current buffer (set to F1 in my emacs)
cmd-tab to last other window (terminal)
'Up' arrow (to reload last compile/run cmd)
'Enter' key
cmd-tab to last other window (emacs), once process terminates
Has saved me thousands of keypresses today.

Related

How can I quickly run one line from a Quarto code chunk that I'm editing in RStudio?

I've just started using Quarto for first time in RStudio (I usually use Rmarkdown).
In Rmarkdown, I could select a line from a code chunk and use Ctrl + ⏎ to evaluate it in the global environment. This was useful because it let test the behaviour of a line without requiring me to knit the document or run the entire chunk.
This shortcut does not work in Quarto documents in RStudio. Is there different keyboard shortcut which will let me a evaluate a single line from a chunk of code in a Quarto document?
Edit: some people are saying that the old shortcut should still work, so maybe this is a bug? I'll update this question when I know more (or perhaps delete the question and submit an issue should the need arise)
Currently using
R version 4.2.1 (2022-06-23 ucrt)
RStudio version 2022.07.1+554 (Spotted Wakerobin)
This is an RStudio bug on Windows 10
There's a known issue with Rstudio and the Quarto visual editor where pressing Ctrl + ⏎ from a 'floating' window results in no code being evaluated, or code in a different window being evaluated. It's part of a wider bug where the connection between floating windows and the main window is severed.
The issue is due for repair in 2024. Until, then you'll need to do the following to restore normal shortcut functionality:
'Re-dock' the window you're editing using the 'Return to main window' button:
Close all other 'floating' windows
Restart RStudio. Close the process completely; restarting the session will not work.

Switching to Terminal for Octave GUI output

I'm trying to figure out why, when I have a large output in the GNU Octave version 4.0.3 running on MacOSX ElCapitan GUI - magic(500) for example - and the "-- less -- (f)orward, (b)ack, (q)uit" prompt comes on screen I have to switch to the terminal to actually execute the command. It's kind of annoying to have to click the terminal just to type "q" so I can continue working in octave-gui after displaying a large output. It would be nice if I didn't have to take up space on my desktop with an open terminal window. I've had the GUI run the command from the command window, but I guess the settings got messed up in some way? Any help on this would be awesome.
You can disable paging within octave using a number of methods listed here.
more off
page_screen_output(false)
page_output_immediately(True)

Copy Paste in Bash on Ubuntu on Windows

How to execute a copy paste operation from Windows 10 to the Bash on Ubuntu on Windows environment?
I tried the following:
ctrl + shift + v
right click to paste
Any suggestions?
Update 2019/04/16: It seems copy/paste is now officially supported in Windows build >= 17643. Take a look at Rich Turner's answer. This can be enabled through the same settings menu described below by clicking the checkbox next to "Use Ctrl+Shift+C/V as Copy/Paste".
Another solution would be to enable "QuickEdit Mode" and then you can paste by right-clicking in the terminal.
To enable QuickEdit Mode, right-click on the toolbar (or simply click on the icon in the upper left corner), select Properties, and in the Options tab, click the checkbox next to QuickEdit Mode.
With this mode enabled, you can also copy text in the terminal by clicking and dragging. Once a selection is made, you can press Enter or right-click to copy.
To get right-click to paste to work:
Right-click on the title bar > Properties
Options tab > Edit options > enable QuickEdit Mode
At long last, we're excited to announce that we FINALLY implemented copy and paste support for Linux/WSL instances in Windows Console via CTRL + SHIFT + [C|V]!
You can enable/disable this feature in case you find a keyboard collision with a command-line app, but this should start working when you install and run any Win10 builds >= 17643. Select "Properties" from the menu to access the following dialog box.
Thanks for your patience while we re-engineered Console's internals to allow this feature to work :)
You can use AutoHotkey (third party application), the command below is good with plain alphanumeric text, however some other characters like =^"%#! are mistyped in console like bash or cmd. (In any non-console window this command works fine with all characters.)
^+v::SendRaw %clipboard%
Right-click the title bar, select context menu Edit -> Paste (until they fix the control key shortcuts)
As others have said, there is now an option for Ctrl+Shf+Vfor paste in Windows 10 Insider build #17643.
Unfortunately this isn't in my muscle memory and as a user of TTY terminals I'd like to use Shf+Ins as I do on all the Linux boxes I connect to.
This is possible on Windows 10 if you install ConEmu which wraps the terminal in a new GUI and allows Shf+Ins for paste. It also allows you to tweak the behaviour in the Properties.
The Console looks like this:
Copy options:
Paste options:
Shf+Ins works out of the box. I can't remember if you need to configure bash as one of the shells it uses but if you do, here is the task properties to add it:
Also allows tabbed Consoles (including different types, cmd.exe, powershell etc). I've been using this since early Windows 7 and in those days it made the command line on Windows usable!
Like it has been written before:
Right Click on Bash on Ubuntu on Windows Icon if you have it on a Task Bar Shortcut Icon
Click on Properties
Select Options Tab on the Properties Window
Check the QuickEditMode option
Click Apply
Now you are able to open a new Bash Terminal and just use Right-Click to paste
In order to be able to copy from Terminal, Just use CTRL+M and this will enable you to select and copy selected Text.
For pasting into Vim in the terminal (bash on ubuntu on windows):
export DISPLAY=localhost:0.0
Not sure how to copy from Vim though :-(
Alternate solution over here, my windows home version Windows Subsystem Linux terminal doesn't have the property to use Shift+Ctrl (C|V)
Use an actual linux terminal]1
Install an X-server in Windows (like X-Ming)
sudo apt install <your_favorite_terminal>
export DISPLAY=:0
fire your terminal app, I tested with xfce4-terminal and gnome-terminal
windows #ubuntu #development
For just copying (possibly long) texts to the Windows clipboard, I have found that just piping the output to clip.exe (including the .exe file extension) works fine for me. So:
$ echo "Hello World" | clip.exe
lets me paste Hello World using Ctrl-V anywhere else.
Now that I have posted this, I notice that related question Pipe from clipboard in linux subsytem for windows includes this and a command solution for pasting from the Windows clipboard as well.
you might have bash but it is still a windows window manager. Highlite some text in the bash terminal window. Right click on the title bar, select "Edit", select "Copy", Now Right Click again on the Title bar, select "Edit" , Select "Paste", Done. You should be able to Highlite text, hit "Enter" then Control V but this seems to be broken
For autohotkey users, a full answer is:
#IfWinActive ahk_class ConsoleWindowClass
^+v::SendInput %clipboard%
Which checks that you're in a console (windows or ubuntu) before pasting from the windows clipboard.
That turned out to be pretty simple. I've got it occasionally. To paste a text you simply need to right mouse button click anywhere in terminal window.

Terminal window inside Sublime Text 2

I saw this project that basically opens a new terminal window from sublime text-2.
What I'm looking for is a way to open the terminal inside sublime text 2 via console.
Does anyone knows how can I do that?
SublimeREPL does what you want
https://github.com/wuub/SublimeREPL/
Of course, there are some limitations because the window of Sublime Text 2 is not originally designed for continuous running buffer of stdin input.
+ 2 years (sorry) - but my solution in ubuntu was to open both sublime and my (real) terminal in the same window, shrink and stretch the terminal to cover the lower portion of the screen, then right click on the terminal and select "keep on top" - works a treat.
EDIT 04/23/2019: Terminus extends TerminalView & adds:
Windows support
Continuous history
Easily customizable themes (see Terminus Utilities)
Unicode support
256 colors support
Better xterm support
Terminal panel view
imgcat support (also works on Linux / WSL)
Bind key shortcut to open shell on file path (e.g. ctrl+alt+t to open):
{
"keys": ["ctrl+alt+t"], "command": "terminus_open", "args": {
"cwd": "${file_path:${folder}}"
}
}
Original Answer:
I've tried pretty much every terminal package around, what you want is TerminalView:
To bind a key shortcut, simply add it to your user key bindings file:
{ "keys": ["ctrl+alt+t"], "command": "terminal_view_open" },
Use Glue. It is a plugin that provides an interface to your shell from the Sublime Text. So basically it a terminal for Sublime Text.
https://packagecontrol.io/packages/Glue
Like #mikko I also decided that due to the limitations of the shell add-ons for sublime to stick with a real terminal window - I've got too used to the F2-F4 workflow of geany.
So really the issue for me is quickly flip-flopping between the two windows easily. To that end, I knocked this up - to be fired from F12 (or whatever you want) in your desktop manager (XFCE in my case)
Note, I launch sublime a from shortcut with terminator -T st3_bash & st3 so I've got a known bash window title for switching focus to.
https://gist.github.com/robertpearce/8725224
I know this code is really, (really) bad, and it'll fail if you have multiple sublime's open, but i don't ever have that anyhow.
Feel free to fork and improve it.
I have always wanted a way to open terminal inside sublime text. After trying out different options I have come to a solution of installing guake terminal as a work around on linux systems, follow the steps below.
Run the command sudo apt-get install guake
Press F12 (for opening terminal)
Now you can use the terminal without leaving sublime.
For windows :
Install Conemu
Have the Quake settings as shown in the pic below
Press ctrl + ~ (for opening terminal)
Note: This is just a workaround. Guake is basically a terminal package for ubuntu-like linux systems.

Annoyance when running scripts in Vim (Windows, Ruby)

I started using vim for my programming projects (mostly Ruby) and mostly everything works just as I want but I have a problem with compiling.
Lets say I am working on a Ruby script and I want to run it. I type :ruby sometging.rb (mapped to some other key). Then vim opens a new cmd.exe window and runs 'ruby something.rb'. Then it waits for me to press ENTER to close the window and continue working on the script.
Is there a way to configure vim on windows so that it always runs the script I'm working on in a separete window (always the same one, if none exists => open one), and not ask me to confirm with enter?
Don't know about gvim, but in normal vim you could put something like
map R <ESC>:tabnew<CR><ESC>:;%!ruby filename.rb<CR>
in your ~/.vimrc which would execute a Ruby file in a newtab when pressing R in command mode.
I've not used Ruby, but for I've found Dr Chip's RunView plugin really useful for running other interpreted languages.
Once it's installed, you can enter:
:RunView! <interpreter>
(where <interpreter> is presumably 'ruby' in your case) and it will open a (vertically if you include the !) split window with the output from passing the contents of the current window to the interpreter. Each time it is run, a new result log is appended to the end of the file (with a date and time stamp separating them).
If you have any issues with it, I'd recommend you contact Dr Chip via the Vim mailing list: he's very helpful (in fact he wrote the original version of RunView in response to a request I made on the mailing list).
This isn't exactly perfect but I use this to launch Python scripts.
command -nargs=* PY3 !start cmd /K Python.exe "%:p" <args>
It starts up a window that stays alive and doesn't interfere with my VIM window. Unfortunately it doesn't load it into an existing window.

Resources