12

Neither Ctrl+T nor Ctrl+O in IdeaVim always return to the previous location when jumping to something in any way.

Yes, after something like Ctrl+], you can jump back to where you came from using Ctrl+O. But there are all kinds of different ways to jump around.

I would like a set of shortcut keys that makes it consistently jump back to where I came from, regardless of how it jumped to something. Be it through a Vim action, or an IDE action, Ctrl+O, and Ctrl+I ought to just let me go back and forth. Right now, it seems like a horrible confusing frustrating mess.

Rohit Gupta
  • 4,022
  • 20
  • 31
  • 41
Mike
  • 2,393
  • 3
  • 25
  • 37
  • 1
    It seems Ctrl+Alt+Left and Right is a better more complete more consistent way to navigate through the various jumps, than what IdeaVim out of the box provides. Instead of moving my right hand to the cursor keys, I would like to remap Ctrl+O to Ctrl+Alt+Left, but this command seems to have no effect: :map – Mike Apr 23 '15 at 22:19
  • 4
    I think I got it. Assign control of Ctrl+O and Ctrl+I to IDE instead of Vim. Then in Keymap, search for Ctrl+Alt+Left, and add Ctrl+O to the shortcut list. Same for Ctrl+Alt+Right, add Ctrl+I to it.\ – Mike Apr 23 '15 at 22:54
  • 2
    Thanks, this works perfectly!!! – WW00WW Sep 07 '18 at 13:03
  • The keyboard respective actions mentioned by @Mike are "Forward" (Ctrl-Alt-Right) and "Backward" (Ctrl-Alt-Left). Just adding this since you can only search by action name, not by shortcut. – AndB Apr 30 '21 at 11:25

3 Answers3

9

Add nmap <C-o> :action Back<CR> to your .ideavimrc file in your home folder.

This back navigation behavior will work better than the default one.

nilsi
  • 10,351
  • 10
  • 67
  • 79
  • This is definitely the way I like to go – ftassi Aug 07 '21 at 14:12
  • Works great, with small modification `nmap :action Back` – Dan Macak Sep 23 '21 at 13:16
  • According to the [Readme](https://github.com/JetBrains/ideavim#executing-actions), `nnoremap` won't work here, hence `nmap`. This makes sense, since `noremap` is all about [expanding](https://stackoverflow.com/questions/3776117/what-is-the-difference-between-the-remap-noremap-nnoremap-and-vnoremap-mapping) key mappings recursively. – mbw Nov 11 '21 at 17:24
  • Updated the answer according to comments. – nilsi Nov 12 '21 at 12:20
3

Right now IdeaVim uses its own jump history not integrated with the jump history of IntelliJ. Feel free to vote for VIM-44.

Andrey Vlasovskikh
  • 16,489
  • 7
  • 44
  • 62
0

I believe since ideavim 2.2.0-eap.1/2.3.0, these workarounds should no longer be necessary.

mbw
  • 352
  • 3
  • 10
  • for me still, if i hit "gi" (go to implementation) then hit control - o, i am not taken back to where i was, but rather some other random file, im assuming a file i have edited with insert. am i doing it wrong? v 2.4.1 – Kevin Crum Aug 23 '23 at 21:28
  • @KevinCrum I tried this out and could not get "gi" to do the right thing. Is this something you defined yourself? It does not come up as "go to implementation" for the shortcuts listed here: https://github.com/JetBrains/ideavim/blob/b8b324cdf37c78c683277c2b57b60dd1069f7067/src/main/java/com/maddyhome/idea/vim/package-info.java#L117 That being aid, I mostly use gd and that seems to work as expected. – mbw Aug 24 '23 at 08:37
  • youre correct, my apologies, i have `nmap gi :action GoToImplementation` however it still makes ctrl o not go back to my previous line of which i invoked `gi` – Kevin Crum Aug 24 '23 at 21:14