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

Throw a error after remove empty line. #137

Open
singlexyz opened this issue Apr 24, 2022 · 1 comment
Open

Throw a error after remove empty line. #137

singlexyz opened this issue Apr 24, 2022 · 1 comment

Comments

@singlexyz
Copy link

I had this config:

      \   {
      \     'buns':     ["[", "]"],
      \     'input':    ['z'],
      \     'kind':     ['add'],
      \     'linewise': 1,
      \     'command':  ["'[+1,']-1g/^\\s*$/d", "'[+1,']-1s/\\(.\\+\\)/\"\\1\",/g", "'[,']normal! =="]
      \   },
      \ ]

1111

It seems that the following replacement error is caused by the deletion of a line

@machakann
Copy link
Owner

Sorry for my late response, and it seems a little difficult situation. Actually, the three commands would not succeed even if executed manually because each command changes the marks '[, '].

A possible workaround is to make a function.

let g:sandwich#recipes += [
\   {
\     'buns': ['[', ']'],
\     'nesting': 1,
\     'input': ['z'],
\     'command':  ['call SandwichQuoteInside()'],
\   },
\ ]

function! SandwichQuoteInside() abort
  let l:start = line("'[") + 1
  let l:end = line("']") - 1
  execute printf('%d,%ds/\(.\+\)/"\1",/g', l:start, l:end)
  execute printf('%d,%dnormal! ==', l:start, l:end)
  execute printf('%d,%dg/^"\s*"$/d', l:start, l:end)
endfunction

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