opengrok is nice if you want code search and navigation in a web interface
Ask HN: How Do You Navigate Code?
11–20 of 39 posts
Re: Ask HN: How Do You Navigate Code?
#12I would just remember some keywords in either code or the file name and do global search, I barely use splits though bc I think it’s kinda distracting.
Re: Ask HN: How Do You Navigate Code?
#13I had a similar requirements some time ago - I thought one nice way would be to write a Markdown file to be read inside VSCode with links to the files' lines/positions, but couldn't find an extension that worked like this. Settled for "Bookmarks" at the time. The "Code Tour" extension can also be used for this.
Re: Ask HN: How Do You Navigate Code?
#14NeoVim + language servers + global search with rg + a bunch of keyboard shortcuts: - gd = go to definition - gr = open a hovering window filled with references to symbol This is enough to get through every codebase I've yet encountered (Go, Typescript, Python, Java, C++). I also like to use and in vim which allows you to jump between the most recently viewed locations. For keeping context, I just write everything dow…
Re: Ask HN: How Do You Navigate Code?
#15Earlier quoted context omitted.
I use these as well, but maybe something I didn't articulate well is that it's often useful to remember where I've been. One thing that I haven't played with in VS Code but that bites me a lot (and sorry, I don't know the proper name for this setting/feature) is that often when you're navigating you're doing so in the same vs code tab. If I remember to double-click the tab it'll hang around, but that's a pretty janky…
Sourcegraph Notebooks PM here. We have a notepad feature you can enable that basically does what you're describing and allows you to create a notebook from the saved content in one click. There's a button to enable the notepad on the notebooks page ( https://sourcegraph.com/notebooks or /notebooks" rel="nofollow">https:// /notebooks ). It follows you around as you navigate search results and files and you can add sea…
Re: Ask HN: How Do You Navigate Code?
#16I 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 use these as well, but maybe something I didn't articulate well is that it's often useful to remember where I've been. One thing that I haven't played with in VS Code but that bites me a lot (and sorry, I don't know the proper name for this setting/feature) is that often when you're navigating you're doing so in the same vs code tab. If I remember to double-click the tab it'll hang around, but that's a pretty janky…
I find VS Code's Outline tool quite handy. By default it's hidden away at the bottom of the main Explorer tab, but you can turn on the Secondary Sidebar (now with a button at the top of the window) and drag it over on to the Secondary Sidebar to really give it room to grow and not fight your file explorer view for space. (Timeline I also like to move into the Secondary Sidebar as a good place for it.)
Outline resembles the Breadcrumbs at the top of an editor and even if you don't have great bookmarks, being able to quickly expand to a specific symbol in a file is handy.
Also Back/Forward mostly work pretty well in VS Code. If you've got the extra mouse buttons that can be used for Back/Forward in a browser those work well, as does the most common browser shortcut Alt+Left and Alt+Right. In very recent versions you can right click the Title Bar and turn on the Command Center and it gives you Back and Forward buttons there in the title bar, even more like a browser.
(ETA: holding Ctrl+Tab gives you a History menu in the order of Back/Forward sort order.)
> One thing that I haven't played with in VS Code but that bites me a lot (and sorry, I don't know the proper name for this setting/feature) is that often when you're navigating you're doing so in the same vs code tab. If I remember to double-click the tab it'll hang around, but that's a pretty janky workflow, and I don't ALWAYS want to do that.
This is called "Preview". If you don't double click to open the file, you can double-click the tab itself later if you decide to want to keep it open. (There's also Keep Open on the context menus and it has a keyboard shortcut of Ctrl+K Enter.)
You can entirely disable Preview with the Settings key "workbench.editor.enablePreview". (Set it to false. Or uncheck it in the UI.) You could make it apply to only a specific workspace while you are trying to navigate it by adding that to a .vscode/settings.json file in the project (though this specific Setting, I probably would try to avoid checking in to your project repo to avoid annoying other users).
Re: Ask HN: How Do You Navigate Code?
#17I should probably use an IDE but I just don't like them. Sublime is insanely fast and lightweight. I don't want to wait for anything to happen and I find my current workflow allows me to navigate codebases quickly anyway.
Re: Ask HN: How Do You Navigate Code?
#18Most code (especially legacy code) has more branches than typically matter: the majority of branches is error handling or special cases and can be ignored when investigating core functionality. Executing the happy path test case for the functionality I want to extend or bug fix and then stepping through the code with a debugger or manually is my usual mode.
I use IntelliJ myself. Being able to step through with a debugger can be a huge help to show actual implementations used in polymorphic code but few test suites are sophisticated enough to guarantee the possibility. Sometimes I will refactor code simultaneously in order to make it more comprehensible; that obviously requires some tests and experience but if you have the tests take the time to gain the experience and otherwise write the tests! Especially BDD style tests, the kind that survive refactoring.
Re: Ask HN: How Do You Navigate Code?
#19Re: Ask HN: How Do You Navigate Code?
#20Earlier quoted context omitted.
Sourcegraph Notebooks PM here. We have a notepad feature you can enable that basically does what you're describing and allows you to create a notebook from the saved content in one click. There's a button to enable the notepad on the notebooks page ( https://sourcegraph.com/notebooks or /notebooks" rel="nofollow">https:// /notebooks ). It follows you around as you navigate search results and files and you can add sea…
I just discovered this feature so I haven't played with it enough yet but it seems to tick all my boxes. One thing that I found confusing about the UX though was that I didn't realize at first I could continue searching around and adding content, so when I added my first bit of content and clicked "Create Notebook" and then subsequently navigated somewhere else and wanted to add content I ended up creating another no…
It might also be more intuitive to clear out the notepad after a notebook is created but curious what you think.
Thanks again for the feedback, feel free to reply here if you have any other thoughts.