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

Lines not wrapping in editor #4622

Closed
aliceell opened this issue Jun 20, 2017 · 8 comments
Closed

Lines not wrapping in editor #4622

aliceell opened this issue Jun 20, 2017 · 8 comments

Comments

@aliceell
Copy link

aliceell commented Jun 20, 2017

I thought the right margin was supposed to look something like this (ignore the syntax highlighting):

image

But it doesn't seem to be working:

image

I have checked "wrap lines" in Preferences > Editor > "Wrap Lines".

Versions and main components

  • Spyder Version: 3.1.2
  • Python Version: 3.6
  • Qt Version: 5.6.2
  • PyQt Version: 5.6
  • Operating system: Windows 7

Dependencies

jedi >=0.8.1 : 0.9.0 (OK) matplotlib >=1.0 : 2.0.0 (OK) nbconvert >=4.0 : 4.2.0 (OK) numpy >=1.7 : 1.11.3 (OK) pandas >=0.13.1 : 0.19.2 (OK) pep8 >=0.6 : 1.7.0 (OK) pyflakes >=0.6.0 : 1.5.0 (OK) pygments >=2.0 : 2.1.3 (OK) pylint >=0.25 : 1.6.4 (OK) qtconsole >=4.2.0: 4.2.1 (OK) rope >=0.9.4 : 0.9.4-1 (OK) sphinx >=0.6.6 : 1.5.1 (OK) sympy >=0.7.3 : 1.0 (OK)
@ccordoba12 ccordoba12 added this to the v3.2.1 milestone Jun 20, 2017
@ccordoba12
Copy link
Member

Thanks for reporting. We'll take a look at this after we release Spyder 3.2.

@aliceell
Copy link
Author

Thank you!

Not sure if this is what the intended behavior is supposed to be, but I noticed that the text eventually does wrap around, just not at the margin line.

image

@rlaverde
Copy link
Member

Not sure if this is what the intended behavior is supposed to be, but I noticed that the text eventually does wrap around, just not at the margin line.

I think this is the intended behavior, the lines wrap according to the width of the editor; the vertical line at 79 characters (edge line) is just a guide, and isn't for wrapping lines.

@ccordoba12 should we add and option for wrapping lines at edge line? although I don't think that option could be useful (I haven't see that option in other editors)

@ccordoba12 ccordoba12 removed this from the v3.2.1 milestone Jun 20, 2017
@ccordoba12
Copy link
Member

ccordoba12 commented Jun 20, 2017

Yeah, you're right. @aliceell, it's a bit unintuitive, but I don't think we're going to fix it.

Thanks for taking the time to report this, though.

@valschmidt
Copy link

Actually, auto-wrapping at the line margin seems both common and useful imo. For example, emacs does this in auto-fill-mode and MATLAB does as well. Otherwise one is left manually wrapping lines continually to make the comments uncluttered. Is there a better way?

@Shinigami-shinto
Copy link

I was just looking into this, it's a usefull feature if you want to print your code on paper (and I actualy want to do this, because I need to major restructuring in my code and it seems easyer to do it on paper :p )

@giacomociani
Copy link

I see this is closed, but I'd like to point out a difference that doesn't seem clearly state here, and may be worth reopening the issue (or transforming it in a feature request).

There is "visual" auto-wrapping, and text-level auto-wrapping.

What Spyder does now, which I think is fine, is visual auto-wrapping to the width of the window. You resize the window, and the width of the lines changes on the fly. However, there is no EOL character inserted in the text source (if I save and open it with a "dumb" editor, it will be a single, long line).

What valschmidt is referring to when it describes the MATLAB editor behavior, however, is on-the-fly text formatting to limit the length of the lines to a predetermined maximum (for which it would makes complete sense to consider the margin line). As you type the code, and reach the margin line, inserts the necessary characters (that depend on the context: comment, code, in parenthesis, etc...) to break the line and continue on the next one.

I think it would be a nice feature to add, and it would be part of the source code automation that Spyder already does (inserting of colons, matching brackets, etc...).

I'm a newby when it comes to Python, but if I understand recommendations correctly, this could be implemented this way. When, while typing, you reach the margin line, Spyder finds the last space characher before the margin line and:

  • if you are in a line comment (starting with "# "), inserts a EOL and starts a new line with "# "
  • if you are in normal code, inside a parenthesis, inserts a EOL and starts a new line with proper indentation
  • if you are in normal code, but not inside a parenthesis, inserts a " ", then EOL and starts a new line with proper indentation

@ccordoba12
Copy link
Member

@giacomociani, making this work on the fly is not easy (although it sounds easy).

The best we can do is to autoformat the text after it's saved to respect the maximum width set by the user. That will come in Spyder 4 beta3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants