Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increment list number at line break #40

Open
seachicken opened this issue Oct 29, 2022 · 1 comment
Open

Increment list number at line break #40

seachicken opened this issue Oct 29, 2022 · 1 comment

Comments

@seachicken
Copy link

The list number is automatically incremented when the enter key is used to create a new line but is not incremented when the o key is used to create a new line.
I often use ESC + o key to create a new line in vim, so it would be easier to type if the number is incremented.
ordered_list

@craftzdog
Copy link
Contributor

I don't know whether it should be a default behavior or not because people may want to just insert a new line without inserting a list bullet/number.

But you can replicate the enter key behavior by making a custom command like so:

inkdrop.onEditorLoad(() => {
  const editor = inkdrop.getActiveEditor();
  const inputField = editor.cm.getInputField();

  const { commands } = inkdrop;
  commands.add(inputField, {
    "custom:insert-below-with-newline": () => {
      commands.dispatch(inputField, "vim:activate-insert-mode");
      commands.dispatch(inputField, "editor:go-line-end");
      commands.dispatch(inputField, "editor:new-line");
    },
  });
});

And bind it in keymap.cson:

'.CodeMirror.vim-mode.normal-mode:not(.key-buffering):not(.visual-mode) textarea':
  'o': 'custom:insert-below-with-newline'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants