Databricks notebooks do not natively support defining custom keyboard shortcuts to insert specific code snippets like Rโs pipe operator () within the notebook editor UI. The list of standard shortcuts available is limited to navigation, cell management, and basic editing actionsโthere is no built-in facility for mapping a shortcut to paste the pipe operator.โ
Workarounds for Pipe Operator Shortcut
If you need this functionality, the most common approaches suggested by users are:
-
Keyboard Macro Tools: Use third-party tools such as AutoHotkey (Windows) or Automator/Keyboard Maestro (Mac) to define a custom macro that pastes %>% whenever you press Shift + Ctrl + M while editing a notebook. This works at the OS level and will function in the browser, including inside Databricks notebooks.โ
-
Browser Extensions: For Chrome users, extensions like "AutoControl Keyboard Shortcut" can allow you to automate keyboard actions, including inserting snippets in web forms (such as code cells in Databricks).โ
No Native Shortcut Editor
Unlike JupyterLab or RStudio (which both allow easy customization of shortcut keys to insert operators directly), Databricks currently does not offer a built-in way to add custom keybindings that paste text in notebooks or code cells.โ
Recommendations
-
For a quick, reliable solution, create a macro using OS-level tools like AutoHotkey (for Windows) or Karabiner-Elements/Automator (for Mac). There are many guides online for creating macros that paste %>% using your preferred shortcut.โ
-
If using Chrome, try an extension that allows you to set up custom shortcuts globally, configuring it to paste the operator when needed.โ
In summary, you cannot set up a native shortcut for the pipe operator in Databricks notebooks, but using external macro or browser tools is a practical workaround for this limitation.โ