Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open 'Go to definition' in other split tab for same file in VS Code?

Tags:

I'm considerably new to Visual Studio Code and I am struggling a bit with an easy functionality. Imagine the case when I am reviewing some code in a file a.py and I select 'Go to definition' on a function x of the same file. Is there any possible configuration or shortcut that opens the definition on a split on the editor?

I have tried having already the same file split in the editor an it still opens the definition in the same file what is uncomfortable when you have to trace some code because you need to scroll up and down whenever you want to see another function of the same file.

An extension that allows to do the trick will also be well received. Thanks.

like image 525
Drubio Avatar asked Jan 10 '19 15:01

Drubio


2 Answers

The shortcut is Ctrl+K, F12 but this can be changed in the shortcuts (search for shortcut editor.action.revealDefinitionAside) More details here https://github.com/microsoft/vscode/issues/112136

like image 24
David Jobet Avatar answered Sep 27 '22 22:09

David Jobet


There are 2 ways to achieve this.

Either:

  1. Left-click function name that you want to open.
  2. Ctrl + t
  3. Ctrl + enter

Or:

  1. Change setting Editor > Goto Location: Multiple to be gotoAndPeek or goto
  2. Ctrl + Alt + [click on function name]

Both methods will open the definition in the split to the right (or create a new split if this is the right-most split).

You like?

like image 131
Rich Avatar answered Sep 27 '22 21:09

Rich