Intellij IDEA with ideavim. Cannot copy text from another source - intellij-idea

I tried to copy text from IDEA with ideavim plugin, using default vim keybindings (y). But this text isn't copied in global buffer and i can paste it only in IDEA.
How can I use copied piece of text in browser, for example?

Vim's yank command doesn't yank to the system clipboard by default; it yanks to the unnamed register. You can use the * or + register to access the system clipboard; also see this wiki article for more information. Or just set this option in your ~/.ideavimrc:
set clipboard+=unnamed
This ~/.ideavimrc setting has been supported in IdeaVim since VIM-476 was implemented in version 0.38. If the file does not exist create it in your user/home directory.
Note also that this is all standard Vim behavior; none of it is specific to IdeaVim except for the name of the config file.

Another option is that you can go to the setting of the ideavim plugin and set ctrl + c and ctrl + v to be handled by the IDE and not by vim.
This will allow you to copy and paste as usual in the IDE and paste outside the IDE as well.
Note
when you set ctrl + v to be handled by the IDE ctrl + v for selection will not work in VIM. As an alternative you might just use ctrl + shift + v in IDE as default (works by default for paste with selection)
Steps
in your lower right corner select settings:
Then search for the shortcut and select the option IDE for handler.

Related

Change IntellIJ terminal to require "Shift" when copy/pasting

By default, IntelliJ has Ctrl + C and Ctrl + V set as copy/paste shortcuts. This also applies to the terminal, though.
This is odd since (on Ubuntu at least) almost every other terminal uses Ctrl + Shift + C and Ctrl + Shift + V for copy/paste shortcuts (and Ctrl + C sends SIGINT).
Changing the copy/paste shortcut in IntelliJ's settings changes the shortcut everywhere, but I don't want it to apply to the editor (just the terminal). This behavior is even mentioned in IntelliJ's terminal help page; https://www.jetbrains.com/help/idea/terminal-emulator.html
The embedded terminal emulator also inherits the following IDE settings:
On the Keymap page, you can configure the copy Ctrl + C and paste Ctrl + V shortcuts.
Is there some hidden setting I'm not seeing somewhere to change the copy/paste behavior of just the terminal in IntelliJ?
It's a known issue with no workarounds available at the moment:
IDEA-230084 In Idea's terminal on Linux, shortcuts Ctrl-C and Ctrl-Shift-C are swapped

Shortcut for locate current file in Project Explorer in IntelliJ?

I read this post:
Locate current file in IntelliJ
Still the problem is that I do not want to have Autosccroll from Source enabled because my Project Explorer will be jumping up and down. Rather I need a shortcut to locate the current file in the Project explorer when I need to. ALT + F1 does work but you need to select from a context menu where you would like the file to be shown. In Resharper for example the shortcut is ALT+SHIFT+L but I am not able to find such a shorcut in IntelliJ?
There is no shortcut for this action in IntelliJ IDEA other than Alt-F1.
There is no default way of doing this.
I can think of 4 options:
You can install the plugin 'Scroll From Source' which will allow you set such a shortcut in the keymap settings (Default: Meta + Ctrl + S)
Use the target symbol in the project explorer, no shortcut but is default option.
Get used to having to press Alt + F1 and then Enter
Record a macro for the above key presses but this may be unreliable. You could then assign a shortcut key to play this marco.

How to disable escaping when copy and pasting in IntelliJ?

When I copy and paste string text into quotes Intellj always escapes certain characters like ", etc,. How can I disable this annoying feature?
You can use Ctrl+Alt+Shift+V (presumably ⌘+Alt / Option+Shift+V for OS X) to do Paste Simple (also available from the right-click context menu). This will paste your most recent clipboard content without escaping it.
Many other programs that offer "simple pasting" will use Ctrl+Shift+V instead, but in IntelliJ that opens an IntelliJ clipboard memory dialog, where you can choose previously copied text to paste.
Note that these are all default, but customizable, keyboard shortcuts.
I found the Ctrl + Shift + Alt + V combination a bit cumbersome, and after some digging I found an alternative solution that was more to my liking. I want to share it here in case it is useful to anyone else.
You can actually edit the key mappings for the paste simple command, and replace them with the standard Ctrl + V that most people are familiar with.
Simply go into File -> Settings -> Keymap and enter "paste" into the search box to bring up all the various paste commands. Double click "Paste Simple" and enter Ctrl + V for the shortcut.
You will be warned that the shortcut is currently assigned and you will be given the option to remove it. After doing so, you have pretty much replaced the annoying "enhanced paste" with the standard "simple paste".
Hope that helps someone out there :)
as of December 2019, at least in IntelliJ Ultimate 2019.3, there is a configuration option to disable this annoying behavior: Go to Editor --> Smart Keys --> Javascript and uncheck the "Escape text on paste in string literals" checkbox.

Using Sublime Text 2 key bindings in PyCharm

I would like to use the Sublime Text 2 key bindings in Pycharm. I know how to edit it one by one. Is there a way to override the entire keymap in one shot?
Something like
export the key bindings from sublime text 2
convert it into Pycharm's format
import it into Pycharm
Pycharm has some pre-configured keymaps. If there's a text / XML / JSON file where these maps are stored, I can try to convert it myself.
PyCharm now has Sublime Text keymap inbuilt as an alternative to Default Keymap.
Go to Setting -> Keymap and select Sublime Text from Keymap dropdown.
Hope that helps.
After poking around, I feel there's no easy way to do this.
If you change the default bindings, PyCharm creates a file in user space that shows the format of keymap. Theoretically, one could override all the fields in this file. But the problem is, there's no standard way of describing the action performed by a shortcut. Someone will have to do it manually, for each macro, to establish a correspondence between the actions performed by PyCharm & Sublime Text.
There is an IntelliJ request for this in their Youtrack tracker: IDEA-111333 Provide Sublime Text keymap.
From that thread, I found a repository for another remapping project. The keybinding file that imitates most of Sublime text can be found at in the directory PHPStorm-SpacePeacock/win_linux-keymaps-only/keymaps/Default for GNOME copy.xml. From the README:
The key mapping has been updated to better fit Sublime Text
conventions. Because I didn't think that ctrl + shift + alt + t is a
reasonable key combination for something as frequently used as
Refactor This.
Additionally, "search everywhere" HAD to be changed because
double-tapping left-shift is a two stroke trigger. This is a problem
because as you're working the IDE will be busy with analyzing,
indexing, and all of the things that IDEs do. If it's busy when you
try to hit the first left-shift, then the second left-shift won't pop
up the window. As far as user interfaces go, you should never have any
lack of confidence that an action will trigger the appropriate
response. Once you have that, you have to visually check each
operation which is slow and creates cognitive overhead. Consequently,
this was changed to ctrl + p (also to match Sublime Text) which
completely removes this problem.
ctrl + p search everywhere
ctrl + r search methods in current file
ctrl + alt + p change projects
ctrl + shift + enter complete current statement
ctrl + alt + enter refactor this
alt + enter show intended actions (intentions are one of my favorite
part JetBrains software)
ctrl + n new thing dialog
ctrl + shift + f format code
ctrl + d select word at cursor, or if a word is selected the select
the next occurrence of the word (multiple-cursors)
ctrl + t run tests
ctrl + alt + h show local history
ctrl + alt + r git conflict merge tool
(Less popular) keymaps that can be used with JetBrains Rider but not included in the installation package.
https://github.com/JetBrains/rider-non-bundled-keymaps
Intalling keymaps
In releases, get the sublime-text-keymap.jar file for the desired keymap.
In your IDE, choose File | Import Settings... from the menu and select the sublime-text-keymap.jar file.

How to mimic Visual Studio's CTRL-X, CTRL-V functionality in Notepad++?

I'm using Notepad++ for some projects and miss Visual Studio's Ctrl + X, Ctrl + C functionality that cuts or copies the entire current line when no text is selected. The cut line shortcut seems to be Ctrl + L, which is not as convenient as Ctrl + X and the copy shortcut seems to be Ctrl + D, Ctrl + L, which is even less convenient.
Although a similar question has been asked before, the way to do this in Notepad++ was not provided and I cannot find a solution on the Notepad++ site or on its forums.
I've created a Notepad++ plugin that does this (without the need of python). An archived version of it can be found at https://bitbucket-archive.softwareheritage.org/projects/za/zastrowm/notepad-visualstudiolinecopy.html.
Synthesizing all other answers and comments, plus some additional necessary steps that haven't been mentioned:
Scintilla provides a "copyAllowLine" command that does this. Notepad++ doesn't expose that command in the shortcut mapper, but you can call it from a Python script and map Ctrl + C to that script. There is no corresponding command for "cutAllowLine", but a bit of extra Python code will do it. These scripts must be added to the menu and Notepad++ must restart before they will become available in the shortcut mapper.
Install Python Script plugin(can be done with Notepad++ Plugin Manager)
Create the following two python scripts using the menu Plugins -> Python Script -> New script
copyAllowLine.py
editor.copyAllowLine()
cutAllowLine.py
if editor.getSelectionStart() == editor.getSelectionEnd():
editor.lineCut()
else:
editor.cut()
Python Script -> Configuration
under User Scripts, add a menu item for each script.
Restart notepad++ (important)
Settings -> Shortcut Mapper...
under Scintilla Commands, remove the existing associations for Ctrl + C and Ctrl + X.
under Plugin commands, find the scripts you just created and map your shortcuts to them.
Note: when installed via plugin manager, version 1.0.6 was installed. When I attempted to run anything python related in Notepad++ I got an unknown exception from plugin manager. The solution was to manually download and install the 1.0.8 .msi from here: 1.0.8 installer
Install NppPython plugin (can be done with Notepad++ Plugin Manager)
Create this python script using the menu Plugins -> Python Script -> New script:
if editor.getSelectionStart() == editor.getSelectionEnd():
editor.lineCut()
else:
editor.cut()
Restart notepad++ (important)
Go to Menu Settings -> Shortcut Mapper -> Plugin commands
Find the script you just created in the list and set CTRL+X shortcut for it
Enjoy!
Go to Settings->Shortcut Mapper and click on the "Scintilla commands" tab at the top. Under there you should be able to change the Ctrl + L command to Ctrl + X.
You can add a script with the Python Script Notepad++ plugin, and assign Ctrl + C to the script (remove the Ctrl + C mapping from SCI_COPY in shortcut mapper, Scintilla Commands tab)
The script is just:
if editor.getSelectionStart() == editor.getSelectionEnd():
line = editor.getCurLine()
editor.copyText(line)
else:
editor.copy()
Obviously just add another similar script for Ctrl-X that removes the line instead.
The plugin from MackieChan: notepad-visual studio line copy
has to be still setup-ed as follow:
Put it into notepad++/plugin folder
open notepad++ (restart)
in Settings -> Shortcut Mapper
under Scintilla Commands, remove the existing associations for Ctrl + C,X
under Plugin commands, find the scripts you just created and map your shortcuts to them.
There is a plugin for it at https://github.com/kbilsted/NppPluginCutNCopyLine its open source and the code is easy to modify if you have extra needs.
you can write a program with a global key event hook, which every time you make a Ctrl + X checks if notepad++ is the foremost application running, grabs the screen, checks if any text is selected (by looking at the screenshot and your notepad++ color settings), and sends a WM_KEYPRESS message to the notepad++ window simulating a Ctrl + L (assuming you're using windows).
(this won't put the line into the clipboard though, you'll have to make some character recognition to allow it)