File History Navigation
Browser-style Back and Forward navigation between files for VSCodium and Visual Studio Code (VS Code).
⚠️ Attention: _The 1.3.0 update had to change the command IDs and setting IDs once again. This is related to how VS Code searches for settings, which is not really documented (and buggy IHMO). You may need to reconfigure your settings and rebind your keys, sorry. I hope this is the last time. I have learned my lesson for my next extensions.
Why this extension exists
VS Code's built-in Go Back and Go Forward commands use a location-based history that also records navigation within a file, such as mouse clicks and jumps to a specific function or code line.
For example, you navigate:
README.md
|
V
example.js (line 50 is active)
|
V
example.js (line 100 is active after clicking it)
If you now select Go Back, VS Code takes you back to line 50 of example.js. That is not how a browser behaves when you select its Back button. I wanted a Go Back command that takes me directly back to README.md, the previous file.
Features
- Keeps a separate file history for each editor group.
- Records file changes only, not cursor movement, selections, scrolling, or other navigation within a file.
- Tracks text and notebook diff views, reopening both sides of the diff during navigation.
- Discards forward history after opening a different file following Back navigation.
- Shows Back and Forward directly in the editor context menu or in a File History submenu.
Commands
Use these commands:
File History: Go BackFile History: Go Forward
To run a command, open the Command Palette with Cmd+Shift+P on macOS or Ctrl+Shift+P on Windows and Linux, search for file history, and select the command.
To assign a shortcut, open Keyboard Shortcuts with Cmd+K Cmd+S on macOS or Ctrl+K Ctrl+S on Windows and Linux. Search for file history, double-click the command's Keybinding column, press the preferred key combination, and press Enter to save it.
Alternatively, run Preferences: Open Keyboard Shortcuts (JSON) from the Command Palette and add these entries to the array in keybindings.json. Replace the sample key combinations with your preferred shortcuts:
[
{
"key": "ctrl+alt+left",
"command": "CodingMarkus.fileHistoryNavigation.command.back"
},
{
"key": "ctrl+alt+right",
"command": "CodingMarkus.fileHistoryNavigation.command.forward"
}
]
The extension does not assign default keyboard shortcuts, pick whatever feels appropriate to you.
Settings
Configure the extension in Settings by searching for file history:
CodingMarkus.fileHistoryNavigation.setting.maxEntries: Sets the maximum number of history entries per editor group. Default:50.CodingMarkus.fileHistoryNavigation.setting.recordDiffViews: Records text and notebook diff views in the history. Default:false.CodingMarkus.fileHistoryNavigation.setting.showInContextMenu: Shows Back and Forward directly in the editor context menu, in a submenu, or not at all. Available values:yes,submenu, andno. Default:yes.
You can also set CodingMarkus.fileHistoryNavigation.setting.maxEntries in settings.json:
"CodingMarkus.fileHistoryNavigation.setting.maxEntries": 50,
"CodingMarkus.fileHistoryNavigation.setting.recordDiffViews": true,
"CodingMarkus.fileHistoryNavigation.setting.showInContextMenu": "yes"
Compatibility
Compatible with VS Code and VSCodium.
Files reopen using their registered editor, including custom, notebook, and binary editors.
Download
Download the extension from
See the release history.
Development
See the development instructions.
License
MIT, see LICENSE.
My other projects
See also my other projects.