Live data from Hacker News

Ask HN: How Do You Navigate Code?

news.ycombinator.com

31–39 of 39 posts

Re: Ask HN: How Do You Navigate Code?

#31

I use VSCode and mostly navigate via: F12: Go to definition Shift+F12: Go to usages Ctrl+-: Go back Ctrl+Shift+-: Go forward Once you get used to it, it's as easy as browsing the web. Since I started using VSCode I did not have to work with codebases that were complex enough to make these features valuable but some VSCode language extensions support tree views of call hierarchies and type hierarchies. Here's the docu…

I think by default go back is Ctrl+Alt+-

Re: Ask HN: How Do You Navigate Code?

#32
IntellIJ IDEA Ctrl-click, Ctrl-Shift-F, Ctrl-U, etc, Sourcegraph when I don't know which repo or do a company-wide code search or examples. Having a lot of tabs open for a single flow of data makes my brain forget about the start of the flow, so I put named bookmarks as I go when doing this. When debugging, the same kind of flow debugging, I use conditionnal non-suspend logging breakpoints that print out relevant stuff from variables in scope. One of the most important parts in this is closing all tabs from time to time, and putting 2 open files side-by-side, 1440p monitor helps, or splitting part of the IDE instance into a separate window on another monitor.

Re: Ask HN: How Do You Navigate Code?

#33
post #27

I use VSCode and mostly navigate via: F12: Go to definition Shift+F12: Go to usages Ctrl+-: Go back Ctrl+Shift+-: Go forward Once you get used to it, it's as easy as browsing the web. Since I started using VSCode I did not have to work with codebases that were complex enough to make these features valuable but some VSCode language extensions support tree views of call hierarchies and type hierarchies. Here's the docu…

Ctrl+- is reduce font size Ctrl+Shift+- is a no-op What version of VScode are you using?

I am on macOS. Keybindings are probably different for Windows and Linux.

Re: Ask HN: How Do You Navigate Code?

#35
If the computation jumps around between multiple files/classes, I document that on paper. Often when working on a new codebase, I end up surrounded by many pieces of paper documenting flows and type hierarchies.

Re: Ask HN: How Do You Navigate Code?

#36
post #32

IntellIJ IDEA Ctrl-click, Ctrl-Shift-F, Ctrl-U, etc, Sourcegraph when I don't know which repo or do a company-wide code search or examples. Having a lot of tabs open for a single flow of data makes my brain forget about the start of the flow, so I put named bookmarks as I go when doing this. When debugging, the same kind of flow debugging, I use conditionnal non-suspend logging breakpoints that print out relevant stu…

This is pretty much exactly what I do now, but since I'm unfamiliar with the codebase I often find myself thinking "where was that spot where this particular data came from?" or "where was that function defined again?" and I just waste a bunch of time & mental energy trying to track it down. Couple that with the fact that this particular codebase uses JavaScript with a custom / modified module system so you can't just cmd+click to go to definition and it's a real headache. It's also exacerbated here by having LOTS of files that have very similar names (Page, PageView, BaseView, BaseViewModel, config.model, config.view are a few examples...) and these are all just under one directory for a given component, if you look there are tons of components all with the same file names, which is a pet peeve of mine, but we all have our preferences I guess. Plus go to definition is great, but sometimes you go down a path that isn't fruitful and it takes a bit to get back to where you wanted to be, and often while I'm going down a path I want to annotate parts of it so it's easier to remember what each piece is doing. Anyway, it seems like bookmarks are a pretty good solution for this in vs code (https://marketplace.visualstudio.com/items?itemName=alefragn...), I just wish I could organize the bookmarks a little bit better than just "show me them by file" or "show me then in an unordered random list".

Edit: Oh and I would normally use the debugger A LOT to trace through the code and understand the call stack and params, but another crappy thing about this project is that it generates a massive JS bundle and it crashes the app I'm testing if I try to put debugger statements in...JS ftw

Re: Ask HN: How Do You Navigate Code?

#37
post #32

IntellIJ IDEA Ctrl-click, Ctrl-Shift-F, Ctrl-U, etc, Sourcegraph when I don't know which repo or do a company-wide code search or examples. Having a lot of tabs open for a single flow of data makes my brain forget about the start of the flow, so I put named bookmarks as I go when doing this. When debugging, the same kind of flow debugging, I use conditionnal non-suspend logging breakpoints that print out relevant stu…

FWIW we (Sourcegraph) have updated our IntellIJ IDEA plugin: https://plugins.jetbrains.com/plugin/9682-sourcegraph

Re: Ask HN: How Do You Navigate Code?

#38
If my code's jumping around a lot I throw some keywords in the comments with unique numbers like verificationworkflow13 so with ctrl-f I can easily jump through the entire chain, or I can go straight to a specific step. Same concept as bookmarking but more flexible and it solves my problem of having a disorganized mess of too many bookmarks. It also helps for keeping things organized in my head ("this is part of the verification workflow between parts 12 and 14").
Post reply on HN