intellij idea ideavim substitute with new line - intellij-idea

In vim, I can substitute a word into two lines like the following
:%s/word/wo^Mrd/g
^M is inserted with Ctrl-V Enter.
But how Can I do this win IntellijJ IDEA, ideavim?
ideavim ignores Ctrl-V in command-line mode.
IntellijIdea 2021.1.1, ideavim.

It's command-line mode, not "command mode", which is synonymous with "normal mode".
IdeaVim being a far from perfect Vim emulator, there is no reason whatsoever to expect it to work like Vim.
The correct way to do what you want in Vim is to use \r:
:%s/word/wo\rrd/g
which, incidentally, works fine in IdeaVim.

Related

ideavim (mac): On doing a paste in normal mode (press `p`), cursor jumps to previous location in editor after pasting

On enabling ideavim plugin (on Mac), while doing a paste operation in normal mode of vim by pressing p, the paste happens but the cursor jumps to the previous location in the editor. This previous location could even be in another file (something similar to Intellij command Cmd+[).
I tried to see if there is a keymap clash with ideavim vs. intellij, but could not find one.
Can this be fixed by changing some keymap entry.. or some option in the Preferences?

How can I enable IdeaVim on only the main editor window?

IdeaVim current replaces essentially all multi-line text inputs. For example, Git commit messages and the Clojure REPL both accept Vim commands. However, in those situations, I'd prefer to have a simple text input, without Vim's features.
Is there any way to enable IdeaVim only on the main editor window, and disable it on all other text inputs? If not, is there any way to disable it or configure it differently for different text inputs?
Thanks!
The following line will disable IdeaVim from dialogs
set ideavimsupport=
As of November 2020 (and IdeaVIM 0.61), this is fully possible by setting the following in your .ideavimrc file:
set dialogescape=off (disables IdeaVIM in all dialogs | defaults to legacy - the old behaviour)
set oneline=off (disables IdeaVIM only in single line boxes | defaults to on)
Currently it's not possible. Feel free to vote for VIM-765 and VIM-740.

Navigating between splits

I wanted to settup vim-tmux-navigation like navigation on intellij IDE and only way to settup this is from IdeaVim so my configuration in settings -> keymap looks like this:
VimWindowDown_____ alt J
VimWindowLeft______ alt L
VimWindowRight_____alt H
VimWindowUp_______ alt K
But when I split the windows it's not working.... Is this a bug or I'm missing some stuff?
Oh and don't suggest me switcher for my problem...
The best place for setting up custom keys for Vim actions is the ~/.ideavimrc file. You can use the standard Vim map/nmap/noremap/imap/... commands there. For example:
nmap <A-J> <C-W>j
For potential keymap conflicts between the Vim emulation and the IDE see Settings | Vim Emulation.
Chaning Vim actions via Settings | Keymap is not recommended.
OK, got a partial answer.
There is a "Go To Next Splitter" and "Go To Previous Splitter" commands in IntelliJ. So in the keymap settings, change or add keystrokes for those commands to C-h and C-l (or whatever you want). If you are using ideavim, don't forget to override those keymap settings so that C-h and C-l are set to use the IDE. C-h and C-l will probably already be used so be sure you don't need the existing hotkey before you make the change.
This solution will at least allow you to move left/right quickly. Not sure it's going to be possible to move between up/down splits without doing some scripting or if that's even possible to do with scripting.

IdeaVIM Keybindings not working in intellij

I just upgraded IdeaVIM to use the newly added support for window management. The problem I'm having is that the keybindings aren't working at all. I've tried editing the keymap manually, adding back the default bindings, but they're not in effect.
When I hit C-w I get some help in the modeline letting me know which keybindings are available at that prefix (l for window right, h for window left etc) but when I hit the second key nothing happens!What's going on here? I'm running ideavim 13.1.3.
NOT exactly the same problem but for me
Vimidea / Vim plugin was not working on Pycharm / Rubymine / Intellij
Finally found the solution!!!
(ON MAC)
Just make sure that you don't have a conflict with the Keymap to refactor->extract->variable and vim emulator!
Go to settings->Keymap->MainMenu->Refactor->Extract->Variable
And remove the shortcut
Now run the shortcut to make the VimEmulator to run, in Mac just hit:
Cmd+option+V (option is the key next to command)
If its still doesn't work it means that you cannot exit insert mode - make sure to bind the escape key to:
settings->Keymap->Plug-ins->ideavim->Exit Insert Mode == escape
Actually using the shortcut to start/stop VimEmulator is a great idea when you ask your team-mate help with your code and he/she is not used to working with Vim.
Just hit cmd+option+V and you are back to using the idea without Vim and again to start working with Vim again :)
You can enable/disble it through: shift-cmd-A, then type ideavim and you'll see a switch on there

Intellij IdeaVim change keys

I would really like to be able to use IdeaVIM but I am unable to figure out where I can set my custom vim key mappings. For example instead of using Esc I would like to use Ctrl-C and instead of using hjkl I like to use wasd.
I have all these already set in my .vimrc but IdeaVIM failed to load them. I can copy them over manually to whatever file is needed but there is no documentation on how to do this.
As of IdeaVim 0.35 (released 2014-05-15), key mappings in ~/.ideavimrc are supported. You can put source ~/.vimrc in that file if you want to include mappings from ~/.vimrc.
Release announcement
VIM-288
(Note: This question could probably be considered a duplicate of this other StackOverflow question.)
I've done this myself, and its pretty easy in IntelliJ 11. I know that in previous versions (9, maybe?) setting up keymap values is significantly different.
In IntelliJ 11 you can do the following:
Go to Settings
Select Keymap from the left menu
Search for Exit Insert Mode on the right side and associate whatever key you want to use, such as CTRL-C
If you like to have Vim plugin installed (I find it very handy for typing) and at the same time have Ctrl+C and Ctrl+V working for copy and paste actions, do the following:
In the IntelliJ Idea, click on File > Setting. On the left pane, expand Editor and click on Vim Emulation.
Here, under the Shortcut column, find Ctrl+C and change it's Handler (under Handler column) to IDE instead of Vim.
Repeat it for Ctrl+V as well and hit Apply and Ok.
Now, you should be able to use the keyboard shortcuts for copy and paste while keeping the Vim Emulator enabled.
IntelliJ 12.1:
Go to Settings
Select Keymap from the left menu
Find Escape under the Editor Actions section and add the Ctrl-C shortcut there. ("Escape" under the "IdeaVim" section didn't work for me)
Following the same steps, but replacing "Escape" with "Exit Insert Mode" only partially worked for me. It exited insert mode correctly but ignored the following keystroke. So typing Ctrl-C,j,j would exit insert but only go up one line instead of two.