Code Editor Shortcuts

approved

by Tim Hor

Add keyboard shortcuts (hotkeys) commonly found in code editors such as Visual Studio Code (VS Code) or Sublime Text.

430 stars48,498 downloadsUpdated 2y agoMIT
View on GitHub

Code Editor Shortcuts

[!NOTE] This project is currently in a maintenance state. I do not have time to actively address any issues on a regular basis. Pull requests and any critical bugs will still be responded to.

This Obsidian plugin adds keyboard shortcuts (hotkeys) commonly found in code editors such as Visual Studio Code or Sublime Text.

CommandShortcut *
Insert line belowCtrl + Enter
Insert line aboveCtrl + Shift + Enter
Delete lineCtrl + Shift + K
Duplicate lineCtrl + Shift + D
Copy line upAlt + Shift + Up
Copy line downAlt + Shift + Down
Join line below to current lineCtrl + J
Select line (repeat to keep expanding selection)Ctrl + L
Add cursors to selection endsAlt + Shift + I
Select word or next occurrence of selectionCtrl + D
Select all occurrences of selectionCtrl + Shift + L
Move cursor upNot set
Move cursor downNot set
Move cursor leftNot set
Move cursor rightNot set
Go to previous wordNot set
Go to next wordNot set
Go to start of lineNot set
Go to end of lineNot set
Go to previous lineNot set
Go to next lineNot set
Go to first lineNot set
Go to last lineNot set
Go to line numberNot set
Delete to start of lineNot set
Delete to end of lineNot set
Transform selection to uppercaseNot set
Transform selection to lowercaseNot set
Transform selection to title caseNot set
Toggle case of selectionNot set
Expand selection to bracketsNot set
Expand selection to quotesNot set
Expand selection to quotes or bracketsNot set
Insert cursor aboveNot set
Insert cursor belowNot set
Go to next headingNot set
Go to previous headingNot set
Toggle line numbersNot set
Indent using tabsNot set
Indent using spacesNot set
UndoNot set
RedoNot set

* On macOS, replace Ctrl with Cmd and Alt with Opt

Important notes

  • Ctrl + Enter for 'Insert line below' may conflict with the default shortcut for Open link under cursor in new tab; changing/removing one of the bindings is recommended.
  • Ctrl + L for 'Select line' may conflict with the default shortcut for Toggle checkbox status; changing/removing one of the bindings is recommended.
  • Ctrl + D for 'Select word or next occurrence of selection' will behave differently depending on how the initial selection was made. If it was also done via Ctrl + D, the command will only look for the entire word in subsequent matches. However, if the selection was done by hand, it will search within words as well.
  • 'Toggle case of selection' will cycle between uppercase, lowercase and title case.
  • If you are looking for the Alt + Up and Alt + Down shortcuts from VS Code, you can assign those hotkeys to Obsidian's built in actions "Move line up" and "Move line down".

Multiple Cursors

Most* of these shortcuts work with multiple cursors. However, undo and redo will not work intuitively in Live Preview – actions will be handled individually for each cursor, rather than grouped together. Work is underway to incrementally migrate them to the newer Obsidian editor API so they are grouped, and has been completed for the following:

  • Insert line above
  • Insert line below
  • Delete line

As a workaround, you can also switch back to the legacy editor in Settings as all actions will be grouped in that case.

* These shortcuts currently do not support multiple cursors:

  • Expand selection to quotes or brackets
  • Go to next/previous heading

Installing the plugin

Refer to the official installation instructions for third-party plugins here and search for the plugin Code Editor Shortcuts.

Configuring settings

Go to Settings → Hotkeys to customise the keyboard shortcut for each action.

The following behaviour can be configured via the settings tab for this plugin:

SettingDescription
Auto insert list prefixAutomatically insert list prefix when inserting a line above or below

Contributing

Contributions and suggestions are welcome – feel free to open an issue or raise a pull request.

To get started:

  • Switch to the specified Node version: nvm use
  • Install dependencies: yarn install
  • Run the extension: yarn start
  • Run tests: yarn test (use --watch for watch mode)

Support

This plugin is completely free to use, but if you'd like to say thanks, consider buying me a coffee! 😄

ko-fi

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.