Can I switch on word wrap in IntelliJ IDEA globally, not for the current project only? Besides, can I get rid of rewriting long lines of text in the form of concatenation? I turned wrap in File -> Settings -> Code Style (Right margin (columns) ... wrap on typing, but still when I use System.out.println("Some long-long line") it appears to be concatenated at first, and I have to change this.
AFAIK, the code formatting settings are organized in schemes, not for the current project.
Open the "Settings"-Dialog, go to "Editor" --> "Code Style" and activate "Wrap on typing". Long lines will be wrapped while you're typing. If you insert a long line from the clipboard, the wrapping is done after pressing CtrlAltL (Windows).
Related
When I use braces in Visual Studio, I press Enter and the brackets are automatically positioned like this:
When I use them in IntelliJ, I have to apply formatting (Ctrl+Alt+L) to make them move:
Is it possible to get this behaviour in IntelliJ? I don't want to have to spam autoformat to make my code the way I want.
It's worth noting that I've specified that my brackets go on the next line in settings:
Filled the bug request to IntelliJ IDEA bug tracker: https://youtrack.jetbrains.com/issue/IDEA-286306
Feel free to follow.
For the time being, you can toggle reformat manually.
I want to indent with tabs, so I checked "Use tab character" in settings. But when I open projects which were indented with tabs, IntelliJ IDEA still asks me if I want to convert the indenting to spaces or keep it that way. Also, it creates new classes with space indenting. How can I solve this?
Your screenshot shows the settings for your Default (1) scheme. Those settings are not applied to your project automatically. It's not enough to just select it in the combobox. You need to import this scheme into your project.
Click Manage... and Copy to Project, and it should work as expected. This needs to be done for all your projects.
Also, make sure you're changing the language-spefic settings, so instead Code Style select Code Style > Java (or whatever language you are using). Those settings may override the default code styles.
When I open up any code file .java or .html IntelliJ (12.x) keeps the code folded and I always have to expand everything.
How do I make code expand by default?
In the preferences (ctrl+alt+s on my machine), under Editor, you will find an entry called Code Folding. In there you can choose what's folded by default. In your case, you'll probably want to remove all the defaults.
I have comments that gets balloon (PEP 8: Line too long ... > 120)
I wish there was a command that will wrap the lines with few keystrokes.
Right now, even if I type Alt+Enter and press enter on Reformat file, nothing actually changes. Is there a setting or plugin I could use to accomplish the formatting easily?
Under the Edit menu, there is a Fill Paragraph option, which does what I believe you want. You can assign a key command to this in Preferences, under Appearance & Behavior -> Keymap (search for "fill").
Personally, I choose first stroke Esc, second stroke Q, because that's what I've always used in Emacs...
Firstly, reformatting won't work, not in Python at least, where whitespace is important. PyCharm's "Wrap when typing reaches right margin" option is what you're looking for. Now this will not work when you copy and paste code, but in the places where it gives you trouble, just press enter, and it will work.
To be able to auto-reformat comments (and code, for that matter) to honor a right margin after the fact, go into Project Settings under Code Style and then further under Python. Click the Wrapping and Braces tab, and check the "Ensure right margin is not exceeded" checkbox.
Now if you select a region of lines and then run the Code/Reformat Code... command, PyCharm will do its best to wrap the comments or code appropriately.
You will probably have to do some tweaking of the results to suit your stylistic taste. For example, I wish PyCharm would do aggressive filling of text in block comments, at least optionally so.
PyCharm will not reformat code such that it becomes invalid Python, so sometimes it will still leave a line longer than the margin (120 or whatever you set under Project Settings/Code Style/General).
With recent PyCharm this now is located at "Editor -> Code Style", with the checkbox named "Wrap on typing"
The Screenshot shows PyCharm version 2016.2.1 Professional.
Updated Answer:
Use "soft wraps." You can search for it in the help bar.
View > Active Editor > Use Soft Wraps
It won't work for existing text or text that's copied in, but will for any newly typed text.
In vim, I can create a rule that highlights lines that are over 80 characters long. Can I do this in IntelliJ? Here's an example in vim:
I don't know if you can highlight. You might have to write a custom Code Inspection for that. But in Settings -> Code Style you can set a right margin of 80 characters and force automatic wrapping once you reach it.
Infact in Settings -> Code Style -> Java under the Wrapping and Braces Tab
there is the option Ensure right margin is not exceeded.
IntelliJ (at least v2016.2 and newer) has exactly this feature.
Under preferences go to: Editor -> Inspections -> General,
Then select: "Line is longer than allowed code style".
You can choose the severity you want, for most severities IntelliJ will underline the characters that exceed the line length limit (but you could change the style of the severity to look exactly like vim if you wanted).
(If it doesn't work, make sure "Right margin (columns):" is set under preferences Editor -> Code Style.)
You could add the JSLint Code Quality Tool.
You can set a maximum line length with that tool... if you so desire, you could disable everything else.
Then, in the Inspections part of your Project settings, enable the JSLint Inspection and set it to whatever Severity you like. This will probable highlight the whole line, but that's close enough, right? :)
I'm sure you've have already resolved this, Rose, but for other people who stumble upon this post, Raystorm's answer was correct. However, in order for the automatic line wrapping to occur, you must auto-format the code by typing Ctrl-Alt-L.