VSCodeVim / Vim

:star: Vim for Visual Studio Code
http://aka.ms/vscodevim
MIT License
13.82k stars 1.31k forks source link

Reliably jump to last cursor location? #7473

Open ivnsch opened 2 years ago

ivnsch commented 2 years ago

I use ctrl+o to jump to the last cursor location (often in combination with ctrl+] to navigate). But sometimes ctrl+o will jump to some unexpected place. Is this a known issue? Haven't paid much attention yet to how exactly it fails - will add more information if I have any.

ivnsch commented 2 years ago

It seems that this happens only when mixing vim navigation with trackpad/mouse. I often use the integrated terminal to compile, and since it's not possible to use shortcuts to navigate there, I use the trackpad. And coming to the code from clicking links on the terminal, it's more natural to navigate further with CMD+click than click+ctrl+] (especially since clicking on the terminal error often doesn't lead to exactly what I want to navigate into).

Not sure whether there's a good solution for this - would it make sense to add non-vim navigation (CMD+click) to the vim history? So it's possible to navigate back using vim shortcuts? Otherwise I'll try to rely mainly on the errors view instead of the terminal, which should be easier to navigate with the keyboard Update: At least with Rust / rust-analyzer this view isn't always up to date (especially when the errors are in tests), so not an option.

akakream commented 7 months ago

I have the same problem very often. I think solving this problem would be a nice improvement.

nullxone commented 4 weeks ago

By default, jumping to a definition then jumping back would jump to the previously open file.

Adding this to keybindings.json (Settings > Open Keyboard Shortcuts (JSON)) works better for me.

  {
    "key": "ctrl+o",
    "command": "workbench.action.navigateBack",
    "when": "editorTextFocus && vim.active && vim.use<C-o> && !inDebugRepl"
  }
ivnsch commented 3 weeks ago

@nullxone what does that address exactly? if the cursor changes file, navigation should go back (or forth) between files too of course.