4

I'm using pycharm with ideavim. I realized I can't control c. This affects normal copy paste flow, but more importantly it means I can't control c from the python console. If I have an infinitely looping program, I'm screwed

Is there anyway to fix this? I looked into the vim emulation settings, but unfortunately it won't let me rebind control c to the IDE.

Vim Emulation Settings

jeremysprofile
  • 10,028
  • 4
  • 33
  • 53
Trevor Aron
  • 179
  • 1
  • 11

3 Answers3

4

Your image is not saying you can't use ^C; it is saying that you don't currently have an IDE bind for ^C. Vim, as you correctly noted, does have one by default, and in the absence of a conflict, PyCharm/IntelliJ will allow Vim to own ^C.

Go to your keymap and search for copy, then add a shortcut to be Ctrl+c as you seem to want. Then you can go back to this screen and select ^C to be managed by the IDE keymap and not the vim one.

That being said, you're not "screwed". The python console that you start with Run or Debug can be stopped with the rectangular red button in the top right corner (it's a rectangular grey button unless you have something actually running). If you hover over it, you can see that it is called "stop" and might already have a keybind associated with it, which you can overwrite in your keybind settings like anything else.

jeremysprofile
  • 10,028
  • 4
  • 33
  • 53
  • 2
    However, how can I send a *KeyboardInterruption*? Clicking the stop button will halt the program... Thanks! – ch271828n Apr 26 '20 at 06:16
  • Nice trick! Adding the shortcut `ctrl+c` to `copy` will make `ctrl+c` appear in the conflict list and then you can assign it to be an IDE. So then you can trigger a `KeyboardInterrupt` also with IdeaVim activated. Only one thing, the red square button kills the entire process, so that's not enough, one needs to use the above trick. – Nisba Aug 30 '21 at 18:36
2

As an alternative to rebinding as described by @jeremysprofile, consider using Ctrl + Insert for copying and Shift + Insert for pasting.

These bindings work system wide out of the box (at least on Windows and KDE, but I think this is some kind of standard for all systems) and are still available in Vim and IdeaVim. This has the advantage of being able to keep using vim's block selection command (Ctrl + V).

Tim
  • 1,430
  • 15
  • 36
1

If your settings Ctrl-c and Ctrl-v in the Vim emulator are handle by Vim you can simply custom your .ideavimrc to use these shortcuts. Here is a simple way to do it, paste this line in your .ideavimrc:

set clipboard+=unnamed

you can refresh the new settings in your IDE without the need to restart the IDE by using the command vim and the path of your .ideavimrc file :

:source ~/.ideavimrc

This method is great, simple and will allow you to use all the editing shortcuts like y, Y, p, P, x to put your code in the clipboard and use it elsewhere on the computer

..

PS : Instead you can also create crazy customized macros for Ctrl-c, Crtl-v in insert, normal or visual mode using the clipboard register by using the quote key " associated with + or * depends and some key editing shortcuts like c,p,y like this :

inoremap <C-v> <Esc>"+Pa

So the behavior is fully customizable (but this is also crazyness)

AlChak
  • 31
  • 3