IntelliJ: Auto-wrapping only for comments? - intellij-idea

Is there a way to enable auto-wrapping only for comments? So far I only found the setting to enable auto-wrapping for everything.

Javadoc comments are covered by
Editor > Code Style > Java > JavaDoc > Wrap at right margin
(So called) single line comments such as ...
// this is a comment
... are another matter. There's no configuration item available in Editor > Code Style > <your_langauage> > Wrapping and Braces to control these.
Edit 1: based on your first reply to this answer: "I am looking for auto-wrapping only for JavaDoc."
Untick this item: Editor > Code Style > Java > Wrapping and Braces > Ensure right margin is not exceeded
Tick this item: Editor > Code Style > Java > JavaDoc > Wrap at right margin
Here's a pair of screenshots showing before and after formatting, with the above configuration in place:
Before
After
The IntelliJ formatter has not wrapped the code (because Editor > Code Style > Java > Wrapping and Braces > Ensure right margin is not exceeded is not ticked) but it has wrapped the Javaodc (because Editor > Code Style > Java > JavaDoc > Wrap at right margin is ticked).

IntelliJ IDEA 2019.1 - Wrap JavaDoc only
Settings > Editor > Cody Style > Java > Wrapping and Braces
Hard wrap at: [Your preferred value for JavaDoc wrapping]
Wrap on typing: No
Keep when reformatting > Ensure right margin is not exceeded: Disabled
If any setting here is set to Wrap if long or Chop down if long, then change it to Do not wrap.
Settings > Editor > Cody Style > Java > JavaDoc
Other > Wrap at right margin: Enabled
Unfortunately, you cannot use "Wrap on typing" for JavaDoc only, because it will wrap code too, even if code wrapping is completely disabled.
Use CTRL+ALT+L to wrap your JavaDoc (Reformat Code).
Settings > Editor > Cody Style > Java > Wrapping and Braces
Settings > Editor > Cody Style > Java > JavaDoc

Related

Can't disable reformatting code when on save files in IntelliJ IDEA

IntelliJ IDEA 2021.2.4 delete whitespaces when saving files.
I set:
Settings > Tools > Actions on Save: All checkboxes disabled
Settings > Editor > Code Style > Formater > Do not format: *.{html,hbs,js,json,py}
Settings > Editor > General > Remove trailing spaces on: disabled
but IntelliJ still change files on each save.

How to change line width in IntelliJ (from 120 character)

I was wondering how I can change the line length in IntelliJ.
Since I use a pretty high resolution, I get that line that shows 120 characters straight through the middle of the screen. Can I change it from 120 to, say, 250?
IntelliJ IDEA 2018
File > Settings... > Editor > Code Style > Hard wrap at
IntelliJ IDEA 2016 & 2017
File > Settings... > Editor > Code Style > Right margin (columns):
You can alter the "Right margin" attribute in the preferences, which can be found via
File | Settings | Project Settings | Code Style - General
Right Margin (columns) In this text box, specify the number of columns
to be used to display pages in the editor.
Source: Jetbrains
It seems like Jetbrains made some renaming and moved settings around so the accepted answer is no longer 100% valid anymore.
Intellij 2018.3:
hard wrap - idea will automatically wrap the line as you type, this is not what the OP was asking for
visual guide - just a vertical line indicating a characters limit, default is 120
If you just want to change the visual guide from the default 120 to lets say 80 in my example:
Also you can change the color or the visual guide by clicking on the Foreground:
Lastly, you can also set the visual guide for all file types (unless specified) here:
It may be useful to notice that very good answers given above may not be enough. It is because of one more tick is required here:
Be aware that need to change both location:
File > Settings... > Editor > Code Style > "Hard Wrap at"
and
File > Settings... > Editor > Code Style > (your language) > Wrapping and Braces > Hard wrap at
I didn't understand why my this didn't work but I found out that this setting is now also under the programming language itself at:
'Editor' | 'Code Style' | < your language > | 'Wrapping and Braces' | 'Right margin (columns)'
Open .editorconfig in the root of your project (or create one if you don't have any) and add:
max_line_length = 80
The IDE should pick it up immediately (works in PhpStorm, developed by the same company). As a bonus, it can be committed to GIT and will stay consistent across different editors you may be using in the future. More info on .editorconfig.

How do I stop PyCharm from autocompleting class methods?

When I type:
def method(, PyCharm jumps in with def method(self):. I would like to disable this behaviour.
The option is located at:
Settings > Editor > Smart Keys > Insert Self...
EDIT: As of pycharm 2017.1 it's under File -> Settings -> Editor -> General -> Smart Keys
Go to File > Settings (or Ctrl+Alt+S) > [IDE Settings] > Editor > Code Completion.
The "Autopopup code completion" setting will determine if the popup opens automatically. Below it, the "Insert selected variant by typing dot, space, etc." is likely the setting you want to turn off.
In PyCharm 2017.1
File -> Settings -> Editor -> General -> Smart Keys -> "Insert 'self' when defining a method"

Intellij editor using \r\n as line break. How to set it using \n only?

I didn't find a setting for this. Source code is fine. But for some shell, \r\n will not work.
Default separator can be changed in the code style settings:
For the existing files you can switch it via the status bar:
IntelliJ IDEA 14 & 16:
Change separator for IDE: File > Settings... > Editor > Code Style > Line separator (for new files):
Change separator for the current file: File > Line Separators
or from the bottom right side (click on CRLF/LF/CR):

SQLDeveloper changing case (breaking formatting)

Using SQLDeveloper 2.1.1.64, if you try typing the following code:
DECLARE
v_status_code NUMBER;
v_status_text VARCHAR2(30);
v_to_delete NUMBER := 5;
BEGIN
PACKAGE_NAME.Delete(v_to_delete, v_status_code, v_status_text);
END;
Pressing Enter after the PACKAGE_NAME.Delete(...) line will make Delete go into all caps (DELETE). I have turned off Case Change in the SQL Formatter options but this still happens. I get other problems similar to this one, where it will randomly reformat lines of code, but I couldn't think of an example as consistent as this. The specific package name doesn't matter, and it does this even if PACKAGE_NAME is in UpperCamelCase.
I don't know if this is a bug with SQLDeveloper or if I'm missing some settings somewhere. It seems as though the SQL Formatter settings under Tools > Preferences > Database > SQL Formatter > Oracle Formatting don't do it, so I don't know what to do. It's getting annoying having to catch some of these format changes, which I sometimes only notice when doing a diff.
Under Tools > Preferences > Code Editor > Completion Insight there is an option for 'Change case as you type'.
But I do not think it will do what you are looking for. Unchecked it will either make it all lower case or all uppercase depending on what you have inputted so far. I am not sure if it will do it the way you are wanting.
I believe you want to disable the annoying option that is changing to UPPERCASE text when you type. Go to Tools > Preferences > Code Editor > Completion Insight > Uncheck "Change case as you type"
Go to Tools > Preferences > Code Editor > Format > Advanced Format > General > change from "lower" to "Keep Unchanged"
Format using Ctrl + F7, it will not change identifier case.