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

How can I break lines in vim? #342

Closed
RidaAyed opened this issue Jun 12, 2018 · 8 comments
Closed

How can I break lines in vim? #342

RidaAyed opened this issue Jun 12, 2018 · 8 comments
Labels
R: duplicate This issue or pull request already exists

Comments

@RidaAyed
Copy link

Howdy! Sorry you're having trouble. To expedite your experience,
provide some basics for me:

Operating system: Linux Arch
Python version: 3.6.65
Black version: Black, version 18.6b2 on Python 3.6.5 (default, May 11 2018, 04:00:52)
[GCC 8.1.0].
Does also happen on master: 🤔

To answer the last question, follow these steps:

  • create a new virtualenv (make sure it's the same Python version);
  • clone this repository;
  • run pip install -e .;
  • make sure it's sane by running python setup.py test; and
  • run black like you did last time.

How can I break lines in vim?

Hi

How can I break lines using :Black to format from this?

headers = {
        'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36',
        }

to that:

headers = {
        'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 \
        (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36',
        }

P.S. Can't answer last question due to:

(blacktest-M_xMekwm) ra @ ~/dev/blacktest/black
master└─ $ pip install -e

Usage:   
  pip install [options] <requirement specifier> [package-index-options] ...
  pip install [options] -r <requirements file> [package-index-options] ...
  pip install [options] [-e] <vcs project url> ...
  pip install [options] [-e] <local project path> ...
  pip install [options] <archive url/path> ...

-e option requires 1 argument
@RidaAyed
Copy link
Author

Does also happen on master: Yes

$ black code.py does NOT break lines as well

@JelleZijlstra
Copy link
Collaborator

You need to do pip install -e . to install from master (don't forget the dot). Is there documentation that has the wrong command?

Breaking up long strings is already an open issue: #182.

@RidaAyed
Copy link
Author

@JelleZijlstra Indeed I've missed the .

@ambv
Copy link
Collaborator

ambv commented Jun 13, 2018

@RidaAyed, the break you're suggesting doesn't do what you think. Since it's a backslash inside a string literal, all the other extra whitespace will be preserved as extra spaces inside the string. If you omit the extra spaces, the line will just wrong being dedented compared to the rest of the code.

What you want is this:

headers = {
    "User-Agent": (
        "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 "
        "(KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
    ),
}

If you're question is about "how to invoke Black from Vim", then the answer to that is "with :Black or ,=".

@RidaAyed
Copy link
Author

Thank you @ambv Lukasz. Yes, you're right, how can I get these lines breaked as you outlined?

@JelleZijlstra
Copy link
Collaborator

That's the issue I linked above; Black doesn't implement it yet.

@ambv
Copy link
Collaborator

ambv commented Jun 13, 2018

@JelleZijlstra, true, but if you format this yourself, Black will keep it.

@ambv
Copy link
Collaborator

ambv commented Jun 20, 2018

Closing this as a duplicate of #182. If there's anything more that's actionable here, please open a new issue.

@ambv ambv closed this as completed Jun 20, 2018
@ambv ambv added the R: duplicate This issue or pull request already exists label Jun 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants