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

Add parens inside multilined parens without line breaks #81

Open
thinca opened this issue Sep 6, 2019 · 4 comments
Open

Add parens inside multilined parens without line breaks #81

thinca opened this issue Sep 6, 2019 · 4 comments

Comments

@thinca
Copy link

thinca commented Sep 6, 2019

Consider the following text:

foo(
   ...
   ...
)

I want to add {} inside () without line breaks:

foo({
  ...
  ...
})

I tried sai({, but I got the following result:

foo(
  {
  ...
  ...
  }
)

How can I get the expected result?

@machakann
Copy link
Owner

machakann commented Sep 20, 2019

Thank you for your report and sorry for my late response. Since the desired behavior is impossible as it is, I am going to add a new choice for linewise option

Currently, I am working on issue81 branch. You can test it with:

call operator#sandwich#set('add', 'line', 'linewise', 3)

or

let g:operator#sandwich#options = {'add': {'line': {'linewise': 3}}}

The above setting works only when you add parentheses with linewise-visual or linewise-motion; for example Vsa( or saj(.

@machakann
Copy link
Owner

I may change the number of option; currently it is 3. Please let me think a little more. Any comments are welcome.

@machakann
Copy link
Owner

Typical examples

Case 1

  • before
foo
bar
baz
  • after (2GVsa()
foo(
bar
)baz

Case 2: lines with indentation

  • before
    foo
    bar
    baz
  • after (2GVsa()
    foo(
    bar
    )baz

@machakann
Copy link
Owner

Corner cases

I'm stil wondering but candidates 1 will be more likely to be adopted.

Only one line in the buffer

  • before
foo
  • after:candidate 1 (Vsa()
(
foo
)
  • after:candidate 2 (Vsa()
(foo)

At the first line

  • before
foo
bar
  • after:candidate 1 (1GVsa()
(
foo
)bar
  • after:candidate 2 (1GVsa()
(foo
)bar

At the last line

  • before
foo
bar
  • after:candidate 1 (GVsa()
foo(
bar
)
  • after:candidate 2 (GVsa()
foo(
bar)

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