holroy
March 23, 2025, 8:28am
4
The first link below shows another feature request with three commands which allows you to switch directly to any mode of your choice. These can then be assigned to three different hotkeys.
@StefanoCecere @AriesOdyssey you can switch between all three modes with a bit of javascript. If you put this in a Templater template, you can add it as a hotkey. Or any other plugin you prefer to launch arbitrary JS.
Source mode
const view = app.workspace.activeLeaf.getViewState()
view.state.mode = 'source'
view.state.source = true
app.workspace.activeLeaf.setViewState(view)
Live preview
const view = app.workspace.activeLeaf.getViewState()
view.state.mode = 'source'
view.state.source = fals…
The following thread shows an option to cycle through all three modes with just one command.
@tophee you can create a template with Templater and assign it to a hotkey or custom button to cycle all 3 modes:
<%*
// Cycle through the three workspace modes
const view = app.workspace.activeLeaf.getViewState()
if (view.state.mode === 'source' && view.state.source === true) {
// In source mode, set to live preview
view.state.source = false
} else if (view.state.mode === 'source') {
// In live preview, set to reading mode
view.state.mode = 'preview'
} else {
// In reading mode, set to so…
Finally here are some other related featute reequests: