Looking for any tips you all might have for making this easier.
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 documentation for the Java extension.
https://code.visualstudio.com/docs/java/java-editing#_call-h...
https://code.visualstudio.com/docs/java/java-editing#_type-h...
You can set keybindings for them too.
Sometimes I do this by just adding a comment, and now that file will at least show up in version control as changed and I can get back to it if I need to, but that's also a little bit janky and I have to be careful I don't leave that cruft around on accident when I commit.
I'm trying out a bookmark extension in VS code and we'll see how it goes, I'm already a little bit annoyed by it in that it doesn't seem to let me organize the bookmarks in any way, so it might be somewhat useful for temporary spelunking, but I won't for example be able to save these bookmarks to refer to them later, which seems like it could be useful.
Sourcegraph has this concept of "Notebooks" which allows you to add files and intermix markdown, which feels like a pretty cool idea, and if I'm just reading code in Sourcegraph it's great, but when I'm in my code editor and making changes I don't want to bounce over to another tool. Maybe it's as simple as keeping some sort of Markdown file open that I write into and then add links to file line numbers as I go, I haven't tried that but I suppose it wouldn't be the worst, and allows me to organize the links in any fashion I see fit.
It follows you around as you navigate search results and files and you can add searches, files, and file ranges to it, as well as notes for each item. Quick demo video: https://storage.googleapis.com/sourcegraph-assets/docs/image...
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).
What version of VScode are you using?
I guess Ctrl+Shift+- is a no op if you haven't first gone back.
Most 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.
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
- <spc>gd = go to definition
- <spc>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 <C-I> and <C-O> in vim which allows you to jump between the most recently viewed locations.
For keeping context, I just write everything down! Either in a scratch file or on a digital notetaking app on my iPad.
nnore <leader>gd :LspGoToDefinition<CR>
...or something like that. I haven't touched the config in a few months.I 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.
In the old days when I did more Java dev, I used Eclipse to view where things are defined and find usages.
Otherwise, searches for file names and contextual links, usages etc.
run strace or ltrace on it;
grep: works better with editor assistance, such as emacs M-x grep;
write documentation for it;
factor out parts of it;
opengrok is nice if you want code search and navigation in a web interface
Take some rough notes on a google doc / gedit so that I don't forget paths that I've explored previously