Go to definition and back to reference in visual Studio Code
I'm currently using VS Code and am trying to use the F12 shortcut which takes me to a definition of and object/function. When I want to go back to the reference, I can't seem to find the right way to do it. With VS community I used shift + F12. I've try different combinations, such as alt + F12 or shift + F12 but all I get is a peek definition of the element which is not useful at all; it's just a popup showing the same element in the same file I'm at. I've seen answers to this question but pertaining to VS 2010 which are no longer applicable or don't work with VS Code.
Question: What is the shortcut to go back once you've used F12 to go to the definition?
visual-studio-code
add a comment |
I'm currently using VS Code and am trying to use the F12 shortcut which takes me to a definition of and object/function. When I want to go back to the reference, I can't seem to find the right way to do it. With VS community I used shift + F12. I've try different combinations, such as alt + F12 or shift + F12 but all I get is a peek definition of the element which is not useful at all; it's just a popup showing the same element in the same file I'm at. I've seen answers to this question but pertaining to VS 2010 which are no longer applicable or don't work with VS Code.
Question: What is the shortcut to go back once you've used F12 to go to the definition?
visual-studio-code
add a comment |
I'm currently using VS Code and am trying to use the F12 shortcut which takes me to a definition of and object/function. When I want to go back to the reference, I can't seem to find the right way to do it. With VS community I used shift + F12. I've try different combinations, such as alt + F12 or shift + F12 but all I get is a peek definition of the element which is not useful at all; it's just a popup showing the same element in the same file I'm at. I've seen answers to this question but pertaining to VS 2010 which are no longer applicable or don't work with VS Code.
Question: What is the shortcut to go back once you've used F12 to go to the definition?
visual-studio-code
I'm currently using VS Code and am trying to use the F12 shortcut which takes me to a definition of and object/function. When I want to go back to the reference, I can't seem to find the right way to do it. With VS community I used shift + F12. I've try different combinations, such as alt + F12 or shift + F12 but all I get is a peek definition of the element which is not useful at all; it's just a popup showing the same element in the same file I'm at. I've seen answers to this question but pertaining to VS 2010 which are no longer applicable or don't work with VS Code.
Question: What is the shortcut to go back once you've used F12 to go to the definition?
visual-studio-code
visual-studio-code
asked Feb 27 '17 at 18:14
Pablo
171129
171129
add a comment |
add a comment |
8 Answers
8
active
oldest
votes
According to the vscode keyboard shortcuts documentation page, the navigateBack action defaults to Ctrl+Alt+-.
In my keybindings.json file, I've rebound it to ctrl+- using:
{ "key": "ctrl+-", "command": "workbench.action.navigateBack" }
I'm not sure but I think that takes you back/forward to where your cursor/highlight text was last, as opposed to toggling between object and definition.
– Pablo
Feb 27 '17 at 20:47
4
@alexriedl is right - Alt+Left works for me. His is the right answer.
– Mark
Feb 27 '17 at 21:09
3
Alt+Left works for me too
– trungk18
Feb 7 '18 at 6:30
add a comment |
For Mac OS it is "^ -" (Ctrl + -) by default.
add a comment |
Shift + F12 should be working for you. There is a box on the right of the peek view which lists all the references. You are seeing the peek view to the reference you went to (the definition) but on the right are more. That boundary between the two can be dragged left and right so perhaps yours is not visible - trying dragging the peek view box right boundary to the left after you hit shift+F12. Do you see a list of references there? Double-clicking the one you started from originally will take you back to it.
[EDIT]
v1.29 added some nice functionality for listing the references in the sidebar. See references view.
List All References
in the context menu or Shift+Alt+F12
Results are stable and individual results can be cleared, which is great if you use the view as a To Do list. You can use F4 and Shift+F4 to navigate through results without taking your hands off the keyboard.
Thanks Mark, you're right. Although it now seems to be working. For some reason I wasn't getting that extra content you mention in that box. It would've been nice for Shift + F12 to have taken you straight to the file it refers to instead of that popup (as VS community does) but, I guess, it's perhaps a matter of taste. Maybe I'm yet to discover how to do it.
– Pablo
Feb 27 '17 at 20:40
add a comment |
You can open the Keyboard Shortcuts
to find the shortcuts.
Preferences -> Keyboard Shortcuts
Search Go
, and will show Go Back
, Go Forward
shortcuts.
In Mac OS,
Go Back
-> ctrl
+ -
Go Forward
-> ctrl
+ shift
+ -
{
"command": "workbench.action.navigateBack",
"key": "ctrl+-"
}
{
"command": "workbench.action.navigateForward",
"key": "ctrl+shift+-"
}
Thanks. I found the Go to implementation which is interesting and other useful shortcuts.
– Pablo
Dec 15 '17 at 17:02
add a comment |
An alternative approach is to use the Ctrl+Alt+Click shortcut, which will open the definition in a new pane to the right. This can then be closed with the usual Ctrl+F4 key combination.
add a comment |
ALT + Left arrow worked for me or Go menu and then Back.
add a comment |
Go to definition F12
Back to declaration Ctrl + F2
add a comment |
Try goto-symbol-stack.
This extension implements a stack tracking the positions only when the goto-definition is triggered by Alt+], and allows the user go back to the reference using Alt+[. No annoying cursor movement in the stock navigation(Alt+←).
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42492925%2fgo-to-definition-and-back-to-reference-in-visual-studio-code%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
8 Answers
8
active
oldest
votes
8 Answers
8
active
oldest
votes
active
oldest
votes
active
oldest
votes
According to the vscode keyboard shortcuts documentation page, the navigateBack action defaults to Ctrl+Alt+-.
In my keybindings.json file, I've rebound it to ctrl+- using:
{ "key": "ctrl+-", "command": "workbench.action.navigateBack" }
I'm not sure but I think that takes you back/forward to where your cursor/highlight text was last, as opposed to toggling between object and definition.
– Pablo
Feb 27 '17 at 20:47
4
@alexriedl is right - Alt+Left works for me. His is the right answer.
– Mark
Feb 27 '17 at 21:09
3
Alt+Left works for me too
– trungk18
Feb 7 '18 at 6:30
add a comment |
According to the vscode keyboard shortcuts documentation page, the navigateBack action defaults to Ctrl+Alt+-.
In my keybindings.json file, I've rebound it to ctrl+- using:
{ "key": "ctrl+-", "command": "workbench.action.navigateBack" }
I'm not sure but I think that takes you back/forward to where your cursor/highlight text was last, as opposed to toggling between object and definition.
– Pablo
Feb 27 '17 at 20:47
4
@alexriedl is right - Alt+Left works for me. His is the right answer.
– Mark
Feb 27 '17 at 21:09
3
Alt+Left works for me too
– trungk18
Feb 7 '18 at 6:30
add a comment |
According to the vscode keyboard shortcuts documentation page, the navigateBack action defaults to Ctrl+Alt+-.
In my keybindings.json file, I've rebound it to ctrl+- using:
{ "key": "ctrl+-", "command": "workbench.action.navigateBack" }
According to the vscode keyboard shortcuts documentation page, the navigateBack action defaults to Ctrl+Alt+-.
In my keybindings.json file, I've rebound it to ctrl+- using:
{ "key": "ctrl+-", "command": "workbench.action.navigateBack" }
edited Aug 7 '17 at 8:14
Andy Li
4,40752838
4,40752838
answered Feb 27 '17 at 20:42
alexriedl
1,6931913
1,6931913
I'm not sure but I think that takes you back/forward to where your cursor/highlight text was last, as opposed to toggling between object and definition.
– Pablo
Feb 27 '17 at 20:47
4
@alexriedl is right - Alt+Left works for me. His is the right answer.
– Mark
Feb 27 '17 at 21:09
3
Alt+Left works for me too
– trungk18
Feb 7 '18 at 6:30
add a comment |
I'm not sure but I think that takes you back/forward to where your cursor/highlight text was last, as opposed to toggling between object and definition.
– Pablo
Feb 27 '17 at 20:47
4
@alexriedl is right - Alt+Left works for me. His is the right answer.
– Mark
Feb 27 '17 at 21:09
3
Alt+Left works for me too
– trungk18
Feb 7 '18 at 6:30
I'm not sure but I think that takes you back/forward to where your cursor/highlight text was last, as opposed to toggling between object and definition.
– Pablo
Feb 27 '17 at 20:47
I'm not sure but I think that takes you back/forward to where your cursor/highlight text was last, as opposed to toggling between object and definition.
– Pablo
Feb 27 '17 at 20:47
4
4
@alexriedl is right - Alt+Left works for me. His is the right answer.
– Mark
Feb 27 '17 at 21:09
@alexriedl is right - Alt+Left works for me. His is the right answer.
– Mark
Feb 27 '17 at 21:09
3
3
Alt+Left works for me too
– trungk18
Feb 7 '18 at 6:30
Alt+Left works for me too
– trungk18
Feb 7 '18 at 6:30
add a comment |
For Mac OS it is "^ -" (Ctrl + -) by default.
add a comment |
For Mac OS it is "^ -" (Ctrl + -) by default.
add a comment |
For Mac OS it is "^ -" (Ctrl + -) by default.
For Mac OS it is "^ -" (Ctrl + -) by default.
edited Aug 21 '17 at 23:29
Buddy
8,56952951
8,56952951
answered Aug 21 '17 at 23:26
Konstantin Nikitin
542610
542610
add a comment |
add a comment |
Shift + F12 should be working for you. There is a box on the right of the peek view which lists all the references. You are seeing the peek view to the reference you went to (the definition) but on the right are more. That boundary between the two can be dragged left and right so perhaps yours is not visible - trying dragging the peek view box right boundary to the left after you hit shift+F12. Do you see a list of references there? Double-clicking the one you started from originally will take you back to it.
[EDIT]
v1.29 added some nice functionality for listing the references in the sidebar. See references view.
List All References
in the context menu or Shift+Alt+F12
Results are stable and individual results can be cleared, which is great if you use the view as a To Do list. You can use F4 and Shift+F4 to navigate through results without taking your hands off the keyboard.
Thanks Mark, you're right. Although it now seems to be working. For some reason I wasn't getting that extra content you mention in that box. It would've been nice for Shift + F12 to have taken you straight to the file it refers to instead of that popup (as VS community does) but, I guess, it's perhaps a matter of taste. Maybe I'm yet to discover how to do it.
– Pablo
Feb 27 '17 at 20:40
add a comment |
Shift + F12 should be working for you. There is a box on the right of the peek view which lists all the references. You are seeing the peek view to the reference you went to (the definition) but on the right are more. That boundary between the two can be dragged left and right so perhaps yours is not visible - trying dragging the peek view box right boundary to the left after you hit shift+F12. Do you see a list of references there? Double-clicking the one you started from originally will take you back to it.
[EDIT]
v1.29 added some nice functionality for listing the references in the sidebar. See references view.
List All References
in the context menu or Shift+Alt+F12
Results are stable and individual results can be cleared, which is great if you use the view as a To Do list. You can use F4 and Shift+F4 to navigate through results without taking your hands off the keyboard.
Thanks Mark, you're right. Although it now seems to be working. For some reason I wasn't getting that extra content you mention in that box. It would've been nice for Shift + F12 to have taken you straight to the file it refers to instead of that popup (as VS community does) but, I guess, it's perhaps a matter of taste. Maybe I'm yet to discover how to do it.
– Pablo
Feb 27 '17 at 20:40
add a comment |
Shift + F12 should be working for you. There is a box on the right of the peek view which lists all the references. You are seeing the peek view to the reference you went to (the definition) but on the right are more. That boundary between the two can be dragged left and right so perhaps yours is not visible - trying dragging the peek view box right boundary to the left after you hit shift+F12. Do you see a list of references there? Double-clicking the one you started from originally will take you back to it.
[EDIT]
v1.29 added some nice functionality for listing the references in the sidebar. See references view.
List All References
in the context menu or Shift+Alt+F12
Results are stable and individual results can be cleared, which is great if you use the view as a To Do list. You can use F4 and Shift+F4 to navigate through results without taking your hands off the keyboard.
Shift + F12 should be working for you. There is a box on the right of the peek view which lists all the references. You are seeing the peek view to the reference you went to (the definition) but on the right are more. That boundary between the two can be dragged left and right so perhaps yours is not visible - trying dragging the peek view box right boundary to the left after you hit shift+F12. Do you see a list of references there? Double-clicking the one you started from originally will take you back to it.
[EDIT]
v1.29 added some nice functionality for listing the references in the sidebar. See references view.
List All References
in the context menu or Shift+Alt+F12
Results are stable and individual results can be cleared, which is great if you use the view as a To Do list. You can use F4 and Shift+F4 to navigate through results without taking your hands off the keyboard.
edited Nov 12 '18 at 23:50
answered Feb 27 '17 at 20:09
Mark
11.1k33249
11.1k33249
Thanks Mark, you're right. Although it now seems to be working. For some reason I wasn't getting that extra content you mention in that box. It would've been nice for Shift + F12 to have taken you straight to the file it refers to instead of that popup (as VS community does) but, I guess, it's perhaps a matter of taste. Maybe I'm yet to discover how to do it.
– Pablo
Feb 27 '17 at 20:40
add a comment |
Thanks Mark, you're right. Although it now seems to be working. For some reason I wasn't getting that extra content you mention in that box. It would've been nice for Shift + F12 to have taken you straight to the file it refers to instead of that popup (as VS community does) but, I guess, it's perhaps a matter of taste. Maybe I'm yet to discover how to do it.
– Pablo
Feb 27 '17 at 20:40
Thanks Mark, you're right. Although it now seems to be working. For some reason I wasn't getting that extra content you mention in that box. It would've been nice for Shift + F12 to have taken you straight to the file it refers to instead of that popup (as VS community does) but, I guess, it's perhaps a matter of taste. Maybe I'm yet to discover how to do it.
– Pablo
Feb 27 '17 at 20:40
Thanks Mark, you're right. Although it now seems to be working. For some reason I wasn't getting that extra content you mention in that box. It would've been nice for Shift + F12 to have taken you straight to the file it refers to instead of that popup (as VS community does) but, I guess, it's perhaps a matter of taste. Maybe I'm yet to discover how to do it.
– Pablo
Feb 27 '17 at 20:40
add a comment |
You can open the Keyboard Shortcuts
to find the shortcuts.
Preferences -> Keyboard Shortcuts
Search Go
, and will show Go Back
, Go Forward
shortcuts.
In Mac OS,
Go Back
-> ctrl
+ -
Go Forward
-> ctrl
+ shift
+ -
{
"command": "workbench.action.navigateBack",
"key": "ctrl+-"
}
{
"command": "workbench.action.navigateForward",
"key": "ctrl+shift+-"
}
Thanks. I found the Go to implementation which is interesting and other useful shortcuts.
– Pablo
Dec 15 '17 at 17:02
add a comment |
You can open the Keyboard Shortcuts
to find the shortcuts.
Preferences -> Keyboard Shortcuts
Search Go
, and will show Go Back
, Go Forward
shortcuts.
In Mac OS,
Go Back
-> ctrl
+ -
Go Forward
-> ctrl
+ shift
+ -
{
"command": "workbench.action.navigateBack",
"key": "ctrl+-"
}
{
"command": "workbench.action.navigateForward",
"key": "ctrl+shift+-"
}
Thanks. I found the Go to implementation which is interesting and other useful shortcuts.
– Pablo
Dec 15 '17 at 17:02
add a comment |
You can open the Keyboard Shortcuts
to find the shortcuts.
Preferences -> Keyboard Shortcuts
Search Go
, and will show Go Back
, Go Forward
shortcuts.
In Mac OS,
Go Back
-> ctrl
+ -
Go Forward
-> ctrl
+ shift
+ -
{
"command": "workbench.action.navigateBack",
"key": "ctrl+-"
}
{
"command": "workbench.action.navigateForward",
"key": "ctrl+shift+-"
}
You can open the Keyboard Shortcuts
to find the shortcuts.
Preferences -> Keyboard Shortcuts
Search Go
, and will show Go Back
, Go Forward
shortcuts.
In Mac OS,
Go Back
-> ctrl
+ -
Go Forward
-> ctrl
+ shift
+ -
{
"command": "workbench.action.navigateBack",
"key": "ctrl+-"
}
{
"command": "workbench.action.navigateForward",
"key": "ctrl+shift+-"
}
answered Dec 13 '17 at 5:02
likid1412
515410
515410
Thanks. I found the Go to implementation which is interesting and other useful shortcuts.
– Pablo
Dec 15 '17 at 17:02
add a comment |
Thanks. I found the Go to implementation which is interesting and other useful shortcuts.
– Pablo
Dec 15 '17 at 17:02
Thanks. I found the Go to implementation which is interesting and other useful shortcuts.
– Pablo
Dec 15 '17 at 17:02
Thanks. I found the Go to implementation which is interesting and other useful shortcuts.
– Pablo
Dec 15 '17 at 17:02
add a comment |
An alternative approach is to use the Ctrl+Alt+Click shortcut, which will open the definition in a new pane to the right. This can then be closed with the usual Ctrl+F4 key combination.
add a comment |
An alternative approach is to use the Ctrl+Alt+Click shortcut, which will open the definition in a new pane to the right. This can then be closed with the usual Ctrl+F4 key combination.
add a comment |
An alternative approach is to use the Ctrl+Alt+Click shortcut, which will open the definition in a new pane to the right. This can then be closed with the usual Ctrl+F4 key combination.
An alternative approach is to use the Ctrl+Alt+Click shortcut, which will open the definition in a new pane to the right. This can then be closed with the usual Ctrl+F4 key combination.
edited Dec 19 '17 at 19:05
Paul Roub
32.6k85773
32.6k85773
answered Dec 19 '17 at 19:01
Tom Ell
856
856
add a comment |
add a comment |
ALT + Left arrow worked for me or Go menu and then Back.
add a comment |
ALT + Left arrow worked for me or Go menu and then Back.
add a comment |
ALT + Left arrow worked for me or Go menu and then Back.
ALT + Left arrow worked for me or Go menu and then Back.
answered Jul 17 '18 at 11:47
Limbo
111112
111112
add a comment |
add a comment |
Go to definition F12
Back to declaration Ctrl + F2
add a comment |
Go to definition F12
Back to declaration Ctrl + F2
add a comment |
Go to definition F12
Back to declaration Ctrl + F2
Go to definition F12
Back to declaration Ctrl + F2
answered Aug 9 '18 at 7:46
kblomqvist
14715
14715
add a comment |
add a comment |
Try goto-symbol-stack.
This extension implements a stack tracking the positions only when the goto-definition is triggered by Alt+], and allows the user go back to the reference using Alt+[. No annoying cursor movement in the stock navigation(Alt+←).
add a comment |
Try goto-symbol-stack.
This extension implements a stack tracking the positions only when the goto-definition is triggered by Alt+], and allows the user go back to the reference using Alt+[. No annoying cursor movement in the stock navigation(Alt+←).
add a comment |
Try goto-symbol-stack.
This extension implements a stack tracking the positions only when the goto-definition is triggered by Alt+], and allows the user go back to the reference using Alt+[. No annoying cursor movement in the stock navigation(Alt+←).
Try goto-symbol-stack.
This extension implements a stack tracking the positions only when the goto-definition is triggered by Alt+], and allows the user go back to the reference using Alt+[. No annoying cursor movement in the stock navigation(Alt+←).
answered Oct 12 '18 at 17:52
lioujheyu
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42492925%2fgo-to-definition-and-back-to-reference-in-visual-studio-code%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown