notebook: Pasting with (remapped) Ctrl+V does not work on Mac
I remapeed copy and paste shortcuts from Cmd
to Ctrl
as meta key (see screenshot below).
While this works nicely overall in Chrome or Safari (not in Firefox, but this is a different story) somehow Jupyter Notebook cannot deal with this. Instead of pasting content when pressing Ctrl+V
the cursorjust jumps to the end of the input field.
Pasting via the menus is working fine though.
Copying content with Ctrl+C
is working fine as well.
The behavior can be seen in all Jupyter input fields. Even in the Jupyter lab settings.
I recently upgraded to Mac Os Mojave. I am not sure if it is the OS upgrade or a jupyter upgrade, but this is something which worked “before”.
Server Information:
You are using Jupyter notebook.
The version of the notebook server is: 5.6.0
The server is running on this version of Python:
Python 3.7.0rc1 (v3.7.0rc1:dfad352267, Jun 12 2018, 01:00:10)
[Clang 6.0 (clang-600.0.57)]
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 3
- Comments: 16
EDIT: seems like the format examples might be misleading… putting this in
~/Library/KeyBindings/DefaultKeyBinding.dict
worked for me… (note=
rather than=>
from examples)Details…
So this appears to be because the Ctrl-v is defined in
/System/Library/Frameworks/AppKit.framework/Resources/StandardKeyBinding.dict
to be mapped to pageDownwhich is what is causing the jumping to the end of the page behaviour. There is a doc here which suggests that modifying:
/Library/KeyBindings/DefaultKeyBinding.dict ~/Library/KeyBindings/DefaultKeyBinding.dict
can be used to override the mappings, but this is not working for me on Mojave 10.14.6
I tried
and various combinations of that, but no luck. Still Ctrl-v jumps to end of page
It worked! Mac OS 10.15.5, tested not in jupyter but in Firefox, but the issue is definitely the same
TL;DR - Create
StandardKeyBinding.dict
like @tolland suggest, but do not use Finder or default text editor - use terminal (e.g.touch
+vi
/nano
)First, it didn’t work for me as well and the problem appears to be in Finder or default text editor of Mac OS: when I was creating a file I was using Finder (xtraFinder) to create a text file. It was created with
.txt
extension that I deleted and edited the file with the default text editor - addedand restart the computer
And nothing happened 😦
Then I go in Finder to the file - it was good. !BUT! When I go to the folder in terminal and do
ls
it showed that file has.txt
extension!So the right way to go is to create a file and content through the terminal (e.g. touch + nano), restart the computer and enjoy the results 😃
Adding
"^v" = "noop:";
in~/Library/KeyBindings/DefaultKeyBinding.dict
does solve the issue in some scenarios (for instance, when you type in Google searching text box). However, it does not affect Jupyter Notebook. When I usectrl-v
the cursor still jumps to the end of input field.So here is the reason. The input field in Jupyter Notebook uses an external tool called CodeMirror, which defines some common shortcuts consistent with my Mac system. Jupyter Notebook has little control over CodeMirror, nor can it modify shortcuts defined in CodeMirror. So I just run below in the first code box in Jupyter Notebook as suggested in this link https://github.com/codemirror/codemirror5/issues/5848 . After this I can use
ctrl-v
to paste text in Jupyter NotebookTo apply
ctrl-v
in all applications, you may also want to change System Setting -> Keyboard -> Keyboard Shortcuts -> App Shortcuts and add (this alone won’t work for Jupyter Notebook)I don’t use Jupyter Interactive Notebook, but I have seen that this bug is recently happening in both Chrome and Safari browsers on the Mac. I wonder if all of these programs are using some kind of the same underlying text editing engine, which is updating for each of these apps at different times.
I have noticed that when I press the (remapped) ctrl-V that the cursor jumps to the end of the input field instead of pasting, but, once that it has jumped there, then, a second press of ctrl-V will paste it there.
amazing! This issues had been puzzling people for so long, a simple upvote seems too lame.
I faced the same problem. Although it was unwilling, I avoided it by overriding only Chrome remapping…
I have this issue with some text entry fields in chrome, but I’ve not tried with Jupyter.
It appears that I can work around the issue with command+shift+v in some cases.