I want to save my current cursor position, move to some other line (in the same file), do some editing and jump back to the original cursor position to continue coding.
Lets say i am in line 50 and realise i need to add a header/library file at line 5. I want save my position here so that i can jump back after making my changes at line 5. How can i do this?
I have looked into cursor navigation shortcuts but they all move cursor by tracing every position cursor was in, and its time consuming and confusing, instead i want to jump back to saved position in one shot.
3
Answers
Thanks @scottfrazer for the suggesting selection anchor.
Thanks @alefragnani for suggesting extensions.
Based on these answers, i wrote a keybinding using multi command extension,
After installing the multi command extension, Add the following snippets in the keybindings.json,
Above snippet will create a key binding for "ctrl+alt+`" (Ctrl + Alt + BackTick).
When pressed,
There is no built-in command for that. The
Go Back
/Go Forward
navigation commands doesn’t allows you to save specific locations.Instead, you should rely on extensions, like my Bookmarks extensions.
There is a bunch of other similar extensions, as you can see on this search https://marketplace.visualstudio.com/search?term=bookmarks&target=VSCode&category=All%20categories&sortBy=Relevance. You should take a look at some, and try out the one that better fit our needs.
Hope this helps
You could use the selection anchor. There is no default keybinding for "Go to Selection Anchor" so you’d have to add one yourself.