machakann/vim-sandwich

linewise always include whole line.

singlexyz opened this issue · 2 comments

For example, I have this text below:

{
  showHeader && <Suspense fallback={null}>
    <Header />
  </Suspense>
}

and I want to change to this:

{
  showHeader && (
    <Suspense fallback={null}>
      <Header />
    </Suspense>
  )
}

Then I press saat) on <Suspense...
ezgif-6-123

Sandwich will put ( in front of the entire line, instead of inserting in front of the selected textobj.

Config:

\   {
\     'buns': ['(', ')'],
\     'input'   : [')'],
\     'linewise'    : 1,
\   },

The option always works line-wise. Thus, never insert a parenthesis in the middle of a line. Probably, what you want is:

\   {
\     'buns': ["(\n", "\n)"],
\     'input' : [')'],
\     'command': ["'[+1,']-1normal! >>"]
\   },

Note that command option may cause wrong highlight.

The option always works line-wise. Thus, never insert a parenthesis in the middle of a line. Probably, what you want is:

\   {
\     'buns': ["(\n", "\n)"],
\     'input' : [')'],
\     'command': ["'[+1,']-1normal! >>"]
\   },

Note that command option may cause wrong highlight.

Thanks, it works.
I also replaced the line with \n generation before, but it directly output (\n.

'buns': ['(\n', '\n)'],

Then I found out that you used double quotes. After I changed it, it was escaped.