Stack line numbers/file locations in vi
A lot of the time I'm reading through code and going from function to function, simulating a call stack. Once I get to the bottom, I need to work my way backwards to see how the returned values are handled, but often times I've forgotten what function (10 or so calls up) was called or where it was in the file.
I recently discovered I can walk through the find history with /^
(forward slash up-arrow). This works, but doesn't always get me exactly what I need.
Is there a way to "bookmark", in order, a list of locations so that I can walk through them in either direction? For example:
- Line 100 -
read_desc
callsdesc_read_dev
- Line 1200 -
desc_read_dev
callsdev_read
- Line 200 -
dev_read
callsout
- Line 10 -
out
returnsEOK
I'd then like to walk that EOK back up to dev_read
and see what happens there, then walk that back to desc_read_dev
etc.
vim vi
add a comment |
A lot of the time I'm reading through code and going from function to function, simulating a call stack. Once I get to the bottom, I need to work my way backwards to see how the returned values are handled, but often times I've forgotten what function (10 or so calls up) was called or where it was in the file.
I recently discovered I can walk through the find history with /^
(forward slash up-arrow). This works, but doesn't always get me exactly what I need.
Is there a way to "bookmark", in order, a list of locations so that I can walk through them in either direction? For example:
- Line 100 -
read_desc
callsdesc_read_dev
- Line 1200 -
desc_read_dev
callsdev_read
- Line 200 -
dev_read
callsout
- Line 10 -
out
returnsEOK
I'd then like to walk that EOK back up to dev_read
and see what happens there, then walk that back to desc_read_dev
etc.
vim vi
add a comment |
A lot of the time I'm reading through code and going from function to function, simulating a call stack. Once I get to the bottom, I need to work my way backwards to see how the returned values are handled, but often times I've forgotten what function (10 or so calls up) was called or where it was in the file.
I recently discovered I can walk through the find history with /^
(forward slash up-arrow). This works, but doesn't always get me exactly what I need.
Is there a way to "bookmark", in order, a list of locations so that I can walk through them in either direction? For example:
- Line 100 -
read_desc
callsdesc_read_dev
- Line 1200 -
desc_read_dev
callsdev_read
- Line 200 -
dev_read
callsout
- Line 10 -
out
returnsEOK
I'd then like to walk that EOK back up to dev_read
and see what happens there, then walk that back to desc_read_dev
etc.
vim vi
A lot of the time I'm reading through code and going from function to function, simulating a call stack. Once I get to the bottom, I need to work my way backwards to see how the returned values are handled, but often times I've forgotten what function (10 or so calls up) was called or where it was in the file.
I recently discovered I can walk through the find history with /^
(forward slash up-arrow). This works, but doesn't always get me exactly what I need.
Is there a way to "bookmark", in order, a list of locations so that I can walk through them in either direction? For example:
- Line 100 -
read_desc
callsdesc_read_dev
- Line 1200 -
desc_read_dev
callsdev_read
- Line 200 -
dev_read
callsout
- Line 10 -
out
returnsEOK
I'd then like to walk that EOK back up to dev_read
and see what happens there, then walk that back to desc_read_dev
etc.
vim vi
vim vi
asked Jan 25 at 14:56
Brydon GibsonBrydon Gibson
377213
377213
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Do you know the :help jumplist
?
Every search (with /
, and n
/N
) and also other motions (that cover more than a short distance, so j
, w
, etc are out) adds an entry there, and you can go back with <C-O>
, and forward again with <C-I>
(which is the same as <Tab>
).
You can also explicitly set a jump point via m'
.
And tags
As your use case is navigation through a call stack, I'd also like to highlight the related tag stack. You need to generate a database of function definitions first (ctags
supports many programming languages), and then there are commands for tag lookup, jumps, and going back in the stack. (All of that is recorded as regular jumps as well.) See :help tags
for details.
Advanced stage
You probably don't need this as a beginner, but plugins like my EnhancedJumps plugin extend the built-in jumplist with jumps that stay inside the current buffer, or the opposite, directly jump to the next location in another buffer.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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%2fsuperuser.com%2fquestions%2f1398401%2fstack-line-numbers-file-locations-in-vi%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Do you know the :help jumplist
?
Every search (with /
, and n
/N
) and also other motions (that cover more than a short distance, so j
, w
, etc are out) adds an entry there, and you can go back with <C-O>
, and forward again with <C-I>
(which is the same as <Tab>
).
You can also explicitly set a jump point via m'
.
And tags
As your use case is navigation through a call stack, I'd also like to highlight the related tag stack. You need to generate a database of function definitions first (ctags
supports many programming languages), and then there are commands for tag lookup, jumps, and going back in the stack. (All of that is recorded as regular jumps as well.) See :help tags
for details.
Advanced stage
You probably don't need this as a beginner, but plugins like my EnhancedJumps plugin extend the built-in jumplist with jumps that stay inside the current buffer, or the opposite, directly jump to the next location in another buffer.
add a comment |
Do you know the :help jumplist
?
Every search (with /
, and n
/N
) and also other motions (that cover more than a short distance, so j
, w
, etc are out) adds an entry there, and you can go back with <C-O>
, and forward again with <C-I>
(which is the same as <Tab>
).
You can also explicitly set a jump point via m'
.
And tags
As your use case is navigation through a call stack, I'd also like to highlight the related tag stack. You need to generate a database of function definitions first (ctags
supports many programming languages), and then there are commands for tag lookup, jumps, and going back in the stack. (All of that is recorded as regular jumps as well.) See :help tags
for details.
Advanced stage
You probably don't need this as a beginner, but plugins like my EnhancedJumps plugin extend the built-in jumplist with jumps that stay inside the current buffer, or the opposite, directly jump to the next location in another buffer.
add a comment |
Do you know the :help jumplist
?
Every search (with /
, and n
/N
) and also other motions (that cover more than a short distance, so j
, w
, etc are out) adds an entry there, and you can go back with <C-O>
, and forward again with <C-I>
(which is the same as <Tab>
).
You can also explicitly set a jump point via m'
.
And tags
As your use case is navigation through a call stack, I'd also like to highlight the related tag stack. You need to generate a database of function definitions first (ctags
supports many programming languages), and then there are commands for tag lookup, jumps, and going back in the stack. (All of that is recorded as regular jumps as well.) See :help tags
for details.
Advanced stage
You probably don't need this as a beginner, but plugins like my EnhancedJumps plugin extend the built-in jumplist with jumps that stay inside the current buffer, or the opposite, directly jump to the next location in another buffer.
Do you know the :help jumplist
?
Every search (with /
, and n
/N
) and also other motions (that cover more than a short distance, so j
, w
, etc are out) adds an entry there, and you can go back with <C-O>
, and forward again with <C-I>
(which is the same as <Tab>
).
You can also explicitly set a jump point via m'
.
And tags
As your use case is navigation through a call stack, I'd also like to highlight the related tag stack. You need to generate a database of function definitions first (ctags
supports many programming languages), and then there are commands for tag lookup, jumps, and going back in the stack. (All of that is recorded as regular jumps as well.) See :help tags
for details.
Advanced stage
You probably don't need this as a beginner, but plugins like my EnhancedJumps plugin extend the built-in jumplist with jumps that stay inside the current buffer, or the opposite, directly jump to the next location in another buffer.
answered Jan 25 at 15:10
Ingo KarkatIngo Karkat
17.6k22544
17.6k22544
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- 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%2fsuperuser.com%2fquestions%2f1398401%2fstack-line-numbers-file-locations-in-vi%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