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

Complex substitute command not working #88

Open
mizlan opened this issue Jun 11, 2023 · 0 comments
Open

Complex substitute command not working #88

mizlan opened this issue Jun 11, 2023 · 0 comments

Comments

@mizlan
Copy link

mizlan commented Jun 11, 2023

Hydra({
  name = 'Coordinate manipulation',
  mode = 'n',
  body = '<Leader>c',
  heads = {
    { 'h', [[<Cmd>s/(\zs-\?\d\+\.\?\d*\ze,\s*-\?\d\+\.\?\d*)/\=str2float(submatch("0"))-0.1<CR>]] },
    { 'l', [[<Cmd>s/(\zs-\?\d\+\.\?\d*\ze,\s*-\?\d\+\.\?\d*)/\=str2float(submatch("0"))+0.1<CR>]] },
    { 'j', [[<Cmd>s/(-\?\d\+\.\?\d*,\s*\zs-\?\d\+\.\?\d*\ze)/\=str2float(submatch("0"))-0.1<CR>]] },
    { 'k', [[<Cmd>s/(-\?\d\+\.\?\d*,\s*\zs-\?\d\+\.\?\d*\ze)/\=str2float(submatch("0"))+0.1<CR>]], { desc = 'small incrs'} },
    { 'H', [[<Cmd>s/(\zs-\?\d\+\.\?\d*\ze,\s*-\?\d\+\.\?\d*)/\=str2float(submatch("0"))-1<CR>]] },
    { 'L', [[<Cmd>s/(\zs-\?\d\+\.\?\d*\ze,\s*-\?\d\+\.\?\d*)/\=str2float(submatch("0"))+1<CR>]] },
    { 'J', [[<Cmd>s/(-\?\d\+\.\?\d*,\s*\zs-\?\d\+\.\?\d*\ze)/\=str2float(submatch("0"))-1<CR>]] },
    { 'K', [[<Cmd>s/(-\?\d\+\.\?\d*,\s*\zs-\?\d\+\.\?\d*\ze)/\=str2float(submatch("0"))+1<CR>]], { desc = 'large incrs'} },
  }
})

I don't think the hydra works correctly for this, the first works but it does not stay in Hydra state and the future h/j/k/l/H/J/K/L are just normal vim motions. Do I need to escape some backslashes in the string? Note that the exact string works with vim.keymap.set()

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

1 participant