Does JupyterLab support a functionality to jump to previously selected or active cell?
Use case #1: sometimes I accidentally hit "Home" or "End" while in Command mode (thinking that I am in Editing mode) and I jump to the very top of my notebook. Then I need to find the place where I was doing the editing.
Use case #2: Sometimes its convenient to do the above on purpose. Jump to the bottom, run a side calculation and then come back to the previously active cell to continue my main line coding.
It would also be nice to assign a shortcut to this command if it exists. I've looked through this github thread, but have not found an appropriate command.
Related
I'm sharing a small but annoying issue that sometimes pops up when I'm using shortcuts to insert operators while working on a markdown file in R : the operator either does not get written, or even worse gets written on another file.
So let's say I am working on the file "report.rmd", and I want to insert the pipe operator using Ctrl+Maj+M, or the assignment operator using "Alt+-", and I have the file "test.R" opened. Well, I therefore type the aforementioned shortcuts and...nothing happens on my markdown file. But some nice operators that had nothing to do there get written on my test.R file.
The only way I found to solve this problem is to close and reopen RStudio (restarting unfortunately doesn't solve the issue).
While this is quite a minor problem, it's incredibly annoying. Did it ever happen to anyone of you, and if so do you know where it comes from and how to solve it?
Edit:
Although I am still running into this issue (without being able to reproduce it consistently) I came into a somewhat lighter solution. Instead of restarting R, simply closing all tabs (closing just the problematic one doesn't work) solves the problem. I hope this helps narrowing down the possible origins of the problem.
Short Answer
re-define the key combo to Ctrl+Shift+ \ , assuming this does not create a conflict
Background
I've had a similar problem for a while, too. In my case, the shortcut never works. I can not find the source. I even found a conflict with Ctrl+Shift+M assigned to 2 Editor functions.
Image:Screen Capture 2 conflicting hotkey assignments
However, a simple key reassignment of the one that is not the pipe operator ("Expand to Matching")
Image:screen capture showing the hotkey conflict solveddidn't solve the issue in my case.
Solution
Here's what did the job for me
I managed to assign a different combo (that hasn't been assigned yet) and that is comfortable enough in the sense of its location on the keyboard
go to Tools → Modify Keyboard Shortcuts...
In the filter box, write "Pipe"
Direct the cursor to the text box showing the current shortcut, and press the new combo (e.g. Ctrl+Shift+ \ ), then Enter.
Remember to hit Apply
Make sure the new Combo isn't a duplicate of another command, by going back to step 1 and sorting the list by Shortcut, then scrolling down to find your new one. if there is an ovelap, consider changing one of them.
There's an option in Jupyter Notebooks where you can select some cells, and then hit F, which opens up a Find & Replace feature.
This shortcut doesn't work in Jupyter Lab. It's not in the Commands list and it's not in the Edit Menu (there is only Find -- and Find Next and Find Previous). Nor can I find a global (not specific to a cell selection) Find & Replace feature.
Does this feature exist? I've found old mentions of it on the internet -- has it been removed? I'm using Jupyter Lab version 1.2.3.
The Find & Replace feature was not removed, but the way it is named in the menu (simply Find...) and the UI which requires the user to click on a small arrow to access it may be confusing. Please see the GIF below which demonstrates how to use the search & replace feature:
If you need a slightly more powerful refactoring tool (i.e. distinguishing the variable scopes) you may want to check out my jupyterlab-lsp project which now includes support for the rename action (see here for a demonstration GIF, but please install a newer version, not the tag linked).
I am not sure if the original question was answered correctly. If I were to find and replace in only a selected cell, the top rated solution doesn't seem to work (in JupyterLab). The desired result is obtained by clicking on the ... button in the F&R menu. Check the attached snippet.
It can be easily done using keyboard in Jupyter as well.
Step 1: If you are inside any code block/cell, press Esc.
Step 2: Press F
While trying to add D&D support to a gnome-shell-extension that I'm writing I ran into a bit of trouble. I can create drop targets to any open window, but that's all I've managed to pull off.
I can't differentiate between the windows. I tried to use global.get_stage().get_actor_at_pos(Clutter.PickMode.ALL, x, y).get_parent().get_parent().get_meta_window().get_wm_class(), but half the time it gives me the wrong window and every now and again it just returns null. Also I'm not sure how to drop the information into the target.
All I'm trying to do is drop a file URI into a browser window or the file into a file manager.
Is it even possible in gnome-shell-extensions and how would I pull it off? Any advice would be welcome!
Here is the current available shell code about DND between windows: https://github.com/GNOME/gnome-shell/blob/master/js/ui/xdndHandler.js You can do practically nothing with it.
In Mutter, there are more than one procedure to handled a drag and drop in a window, because there are one implementation for X11-windows and another implementation for Wayland-windows.
To be honest, i don't know if there are a way on Wayland and how will be.
I can tell you that in gnome-shell (Mutter to be specific) there are not a fully implementation of this ability on X11. Most you can know, it's if a drag and drop occurs from a window to the shell and the position of the dragged actor, but the shell dosen't provide any api to create an internal drag and drop from the shell to a particular window.
The shell drag and drop that you can fully used, it's only an internal (just the shell) drag and drop from and to the shell (only for clutter actors) and not an external one between different windows.
In X11, the drag and drop process occurs between windows only. One window provide the dragged object and the information that it's associate to that object. The another window (could be the same) will accept the drop of the object, taking on account the information that the first window provide.
As there are not way in the shell to be possible setting the requiered information to the target-window and like your GUI is inside a big top window (The window that represent the shell global stage: https://github.com/GNOME/mutter/blob/6c18bae83cd27a7397a1ed0c1c0c81b282f1b44e/src/compositor/meta-dnd.c#L152) and like you don't have access to this big internal window, finally you can not do anything to interact directly with other windows.
Here (https://github.com/swayfreeda/blender-2.77a/tree/5969d704f44952ea8cbecba2ba4150fb4a48e6de/extern/xdnd) you can find a fully implementation of drag and drop on X11, you will need to modify the code to be adapted to the Mutter workflow and then add this code to Mutter. After that you will have support, but you will need to create the corresponding procedured to then invoked the functionalities, provide information and recive usefull events from the shell to the window, to be possible finally control it in gjs, but it will be only for X11, not for Wayland. I suppose you will need to do something similar if you want support on Wayland.
Good loock.
If I type a line of R code at the cursor and press 'Enter' I can immediately retrieve that code by pressing the up-arrow key once. However, if I am typing a line of code and accidentally press the down-arrow key once then that line of code disappears and I cannot retrieve it. This is a minor, but ever-present annoyance, most frustrating when typing data into a vector.
Is there a way to retrieve a line of code after accidentally pressing the down-arrow key?
I am using a Windows machine and the R GUI found on my desktop immediately after installation... ...I think one of the questions during installation is whether I want a short-cut on my desktop, and I select 'yes'.
this is completely dependent on the GUI. I believe (but am not certain) that RStudio, for example, preserves what you have typed.
While not a direct solution, what might be helpful is to use edit in an external window. I dont use windows, but I suspect if you hit ctrl+n you will get an editor in which you can then use F5 or ctrl+R to execute that specific line.
Personally, I use Sublime Text 2, and cmd+enter gets my code executed at the console
I found that if I open R and click File then New Script in the R menu an editor will open. I can type a line of R code in that editor. Then I can highlight that line of code and press Ctrl+R, as mentioned in Ricardo Saporta's answer and djhurio's comment. By pressing Ctrl+R that line of R code will execute. The line of R code remains visible in the editor and seems safe from being lost even if I accidentally hit the down-arrow key.
Hopefully this builds on Ricardo Saporta's answer enough to warrant being posted as another answer, although I would not have figured this out without Ricardo's and djhurio's help.
P.S.
In retrospect, I see now this is what Ricardo meant in his second comment beneath his answer.
I am doing some analysis in Rstudio and at the moment - as I am refreshing my knowledge of R after a few decades away from S - this involves writing lots of one-liner statements which operate on test datasets, and then inspecting/testing the output, then finally scaling it up when I've checked all the little bits work.
So my history is full of syntax errors and similar. But I am making progress every time I work, and each time I work there are statements that worked, that I want to save, in order to document the bits of the session that are worth saving. Is there any established way of extracting these from my history for re-use, in RStudio? Should I just scroll through after each session and copy and paste them into a textfile with a word processor? Or is there something more clever than that that I can do, staying within RStudio?
The easiest way to see your history, is to hit Ctrl-4 and that will bring up the history window. You can copy this to source and then edit it, or where ever. However, for what you are doing it is probably better to edit directly into a source window.
The setup I use is to have a script window open, and use ctrl-enter to run the current line.
To make this easier go into Tools>Options>Code Editing and ensure that "focus console after executing from source" is unchecked and your cursor will stay in the script after the line is executed.
You can now type your lines and edit them until they do what you want, then move on to the next when it works. Once you get to the end you have built up your script already. Also since your "history" is just their in front of you, it is much easier to skip back to older lines and rerun or modify them. If you want to run a block of code, simply highlight the block and hit ctrl-enter.
In the history panel in RStudio (top right panel), you can click "send to source" and it will copy the line you have selected over to whatever .R file you have open in the top left panel.