Shortcut to Toggle Wordwrap?

Hey there,

Is there a way to configure a shortcut to toggle wordwrapping natively inside of Inkdrop?

Hi Alex,

Yes, that’s possible by making a custom command and assigning a keymap to it.

First, create a custom command in your init.js like so:

inkdrop.commands.add(
  document.body,
  'custom:toggle-line-wrapping',
  (event) => {
    const lineWrapping = inkdrop.config.get('editor.lineWrapping')
    inkdrop.config.set('editor.lineWrapping', !lineWrapping)
  }
)

You can dispatch the command manually as follows:

inkdrop.commands.dispatch(document.body, 'custom:toggle-line-wrapping')

Assign a shortcut in your keymap.json:

{
  ".CodeMirror textarea": {
    "ctrl-alt-l": "custom:toggle-line-wrapping"
  }
}

Related API docs

1 Like

Could this eventually be enabled in the application itself? If not, I’d imagine I could pretty easily turn this into a plugin.

I think it’d be nice to have a command like editor:toggle-line-wrapping and let you invoke it via the command palette, which is planned in the current roadmap.
This way, you don’t have to map shortcuts for every setting like Vim (:set wrap).