Word wrap intellij idea

How would be possible to assign a shortcut for word wrap like as sublime text do? i.e. if the code line is too long it should be automatically break to the next line. wikipedia.org.org/Word_wrap

This code should be wrapped out

asked Apr 11, 2014 at 5:53

Sayat Satybald's user avatar

Sayat SatybaldSayat Satybald

6,2105 gold badges33 silver badges52 bronze badges

3

I think «soft wrap» might be what you’re after. It’s read-only, i.e. does not change the characters in the file, it only wraps what you see on screen.

settings soft wrap
Intellij >= 14.1.4: As pointed out by looper in the comments, the options are under File > Settings > Editor > General — under the Virtual Space or Soft Wraps sub-group.

Intellij < 14.1.4: Look under File > Settings > Editor > Virtual Space.
It doesn’t have a shortcut by default, but you can assign one in the keymap.

AndroidStudio >= 1.4.1: the options are under File > Settings > Editor > General — under the Soft Wraps sub-group.

You can also right click the gutter (the vertical bar where line number is shown) and select «Use Soft wraps» — thanks to Bajal for comment.
gutter soft wrap

To assign a shortcut for toggling softwrap: Look under File > Settings > Keymap, search for «softwrap», then assign your preferred shortcut.

answered Apr 14, 2014 at 23:34

Shorn's user avatar

ShornShorn

18.3k14 gold badges87 silver badges157 bronze badges

6

[ctrl+alt+s] or File->settings to open settings dialogue.

Search for code style. its under project settings.

In code style, General check

wrap when typing reaches margin

That will give you wrapping of code.

answered Apr 11, 2014 at 8:53

Dineshkumar's user avatar

DineshkumarDineshkumar

4,1475 gold badges28 silver badges43 bronze badges

3

One can also right click the gutter (the vertical bar where line number is shown) and select «Use Soft wraps» — thanks to Bajal for comment.

This is the easiest way, and i found it in comments. I think it should be an answer so everybody can see it easily.

answered May 22, 2018 at 13:55

acpuma's user avatar

acpumaacpuma

4795 silver badges15 bronze badges

In order to wrap text in the code editor in IntelliJ IDEA 2020 follow these steps:

  1. Crtl + Shift + «A» OR Help -> Find Action
  2. Enter: «wrap» into text box
  3. Toggle: View | Active Editor Soft-Wrap «ON»

Image of Toggle Switch in Menu

Ardent Coder's user avatar

Ardent Coder

3,7179 gold badges28 silver badges52 bronze badges

answered May 8, 2020 at 3:42

Noah PG's user avatar

Noah PGNoah PG

1512 silver badges3 bronze badges

In the Community Edition, Do Following:

File >> Settings >> Editor >> Code Style >> Java

Go to Wrapping And Braces Tab.

Set the «Right margin (columns)» option with number of columns you would like as line wrapping point.
Set «Wrap on typing» to YES.

Don’t forget to apply the changes before you click Ok.

AlexW's user avatar

AlexW

8567 silver badges9 bronze badges

answered Apr 7, 2016 at 16:22

Vishal's user avatar

VishalVishal

1,8632 gold badges19 silver badges22 bronze badges

For IntelliJ IDEA Version: 2019.3

  1. Go to File > Settings

  2. A new window will appear

  3. Select Editor > General

Navigate to Soft Wraps section, check the box, and using a semi-colon as the delimeter, * and ? as wildcards, add the desired file-extensions.
Select Apply and you are good to go.

Screenshot of Settings window

answered Dec 15, 2019 at 9:44

The answer to this question is:

Use the option Ensure right margin is not exceeded — the bottom option in the screenshot:

enter image description here

answered Dec 6, 2020 at 0:01

ACV's user avatar

ACVACV

9,7205 gold badges72 silver badges81 bronze badges

Right click anywhere on the number of lines bar and click soft-wrap

enter image description here

Or you can just go to View -> Active Editor -> Soft-Wrap

answered Jun 20, 2022 at 3:13

Skidee's user avatar

SkideeSkidee

5275 silver badges8 bronze badges

(In Community Edition 2016+) go : IntelliJ IDEA>Preferences >Editor>General: select options «Use soft wraps in editor» and «Use original line’s indent for wrapped parts»

answered Apr 1, 2016 at 23:20

Alferd Nobel's user avatar

Alferd NobelAlferd Nobel

2,8912 gold badges29 silver badges34 bronze badges

OS X 10.8 IntelliJ Idea 15.0.5:
IntelliJ IDEA Menu/Preferences/Editor/General/Soft Wraps

answered Apr 20, 2016 at 5:18

Gyuri's user avatar

GyuriGyuri

4,4284 gold badges34 silver badges43 bronze badges

The gutter’s context menu has a soft wrap option. Right-click on the gutter located to the far left of the editor to reveal the menu

enter image description here

answered Mar 29, 2022 at 23:12

Testilla's user avatar

TestillaTestilla

5907 silver badges21 bronze badges

It can help.
Thats the solution I have found, when I was trying the wrap the codelines, in the code-editor, when I was decreasing/increasing(stretching) the window-code-editor.

enter image description here

answered Aug 15, 2020 at 17:20

GtdDev's user avatar

GtdDevGtdDev

6985 silver badges13 bronze badges

It helped me adding » *.java» after » *.adoc;» because in «Settings», then «General» and then » Soft-wrap these files:» I had only » *.md; *.txt; *.rst;
*.adoc «. If after that you add «; *.java» your long java code will be wrapped to a new line.
Thx for the screens. It helped me a lot.

answered Jul 11, 2021 at 22:50

MonaRad's user avatar

Use this page to configure formatting options for Java files. When you change these settings, the Preview pane shows how this will affect your code.

Tabs and Indents

Item

Description

Use tab character

  • If this checkbox is selected, tab characters are used:

    • On pressing the Tab key

    • For indentation

    • For code reformatting

  • When the checkbox is cleared, IntelliJ IDEA uses spaces instead of tabs.

Smart tabs

  • If this checkbox is selected, the part of indentation defined by the nesting of code blocks, is made of the tabs and (if necessary) spaces, while the part of indentation defined by the alignment is made only of spaces.

  • If this checkbox is cleared, only tabs are used. This means that a group of spaces that fits the specified tab size is automatically replaced with a tab, which may result in breaking fine alignment.

The Smart tabs checkbox is available if the Use tab character checkbox is selected.

Tab size

In this field, specify the number of spaces included in a tab.

Indent

In this field, specify the number of spaces to be inserted for each indent level.

Continuation indent

In this field, specify the number of spaces to be inserted between the elements of an array, in expressions, method declarations and method calls.

Keep indents on empty lines

If this checkbox is selected, IntelliJ IDEA will keep indents on the empty lines as if they contained some code.

If this checkbox is cleared, IntelliJ IDEA will delete the tab characters and spaces.

Label indent

In this field, specify the number of spaces to be inserted at the next line before a label statement.

Absolute label indent

If this checkbox is selected, label indentation is counted as an absolute number of spaces. Otherwise, label indentation is counted relative to previous indent levels.

Do not indent top level class members

Select this checkbox to have top level class members located at the class declaration indentation level.

Use indents relative to expression start

Use this checkbox to switch between the two possible indentation behaviors:

  • If this checkbox is not selected, the blocks of code will be formatted against the closest ancestor block that starts on a new line.

  • If this checkbox is selected, the blocks of code will be formatted in columns.

Spaces

Use this tab to specify where you want spaces in your code. To have IntelliJ IDEA automatically insert a space at a location, select the checkbox next to this location in the list. The results are displayed in the preview pane.

Wrapping and Braces

In this tab, customize the code style options, which IntelliJ IDEA will apply on reformatting the source code. The left-hand pane contains the list of exceptions (Keep when reformatting), and placement and alignment options for the various code constructs (lists, statements, operations, annotations, and so on) The right-hand pane shows the preview.

Alignment takes precedence over indentation options.

Hard wrap at

Use the Hard wrap at field to specify a margin space required on the right side of an element. If you select the Default option, then a value of the right margin from the global settings is used.

Wrap on typing

Use the Wrap on typing settings to specify how the edited text is fitted in the specified Hard wrap at:

  • Default: in this case IntelliJ IDEA uses the Wrap on typing option that is specified in the global settings.

  • Yes: in this case IntelliJ IDEA uses the value specified in the Right Margin field.

  • No: in this case this option is switched off and a line can exceed the value specified in the right margin.

Visual guides

Use the Visual guides field to specify multiple right margins. You can leave a default value or enter the number of spaces for your margin. If you want to specify several margins, enter numbers separated by comma.

Keep when reformatting

Use the checkboxes to configure exceptions that IntelliJ IDEA will make when reformatting the source code. For example, by default, the Line breaks checkbox is selected. If your code contains lines that are shorter than a standard convention, you can convert them by disabling the Line breaks checkbox before you reformat the source code.

Wrapping options

The wrapping style applies to the various code constructs, specified in the left-hand pane (for example, method call arguments, method declaration parameters, or assignment statements).

Item

Description

Wrapping style

From this list, select the desired wrapping style:

  • Do not wrap: when this option is selected, no special wrapping style is applied.

    With this option selected, the nested alignment and braces settings are ignored.

  • Wrap if long: select this option to have lines going beyond the right margin wrapped with proper indentation.

  • Wrap always: select this option to have all elements in lists wrapped, so that there is one element per line with proper indentation.

  • Chop down if long: select this option to have elements in lists that go beyond the right margin wrapped, so that there is one element per line with proper indentation.

Alignment options

Item

Description

Align when multiline

If this checkbox is selected, a code construct starts at the same column on each next line. Otherwise, the position of a code construct is determined by the current indentation level.

<character(s)> on next line

Select this checkbox to have the specified character or characters moved to the next line when the lines are wrapped.

‘else’ on new line

Use this checkbox to have the corresponding statements or characters moved to the next line.

New line after <character>

Select this checkbox to have the code after the specified character moved to a new line.

Special ‘else if’ treatment

If this checkbox is selected, else if statements are located in the same line.

Otherwise, else if statements are moved to the next line to the corresponding indent level.

Indent ‘case’ branches

If this checkbox is selected, the case statement is located at the corresponding indent level. Otherwise, case statement is placed at the same indent level with switch.

Braces placement options

Item

Description

Braces placement style

Use this list to specify the position of the opening brace in class declarations, method declarations, and other types of declarations. The available options are:

  • End of line: select this option to have the opening brace placed at the declaration line end.

  • Next line if wrapped: select this option to have the opening brace placed at the beginning of the line after the multiline declaration line.

  • Next line: select this option to have the opening brace placed at the beginning of the line after the declaration line.

  • Next line shifted: select this option to have the opening brace placed at the line after the declaration line being shifted to the corresponding indent level.

  • Next line, each shifted: select this option to have the opening brace placed at the line after the declaration line being shifted to the corresponding indent level, and have the next line shifted to the next indent level as well.

Force braces

From this list, choose the braces introduction method for if, for, while, and do () while statements. The available options are:

  • Do not force: select this option to suppress introducing braces automatically.

  • When multiline: select this option to have braces introduced automatically if a statement occupies more than one line. Note that IntelliJ IDEA analyzes the number of lines in the entire statement but not only its condition.

    IntelliJ IDEA will insert braces automatically:

  • Always: select this checkbox to have braces always introduced automatically.

Chained method calls

Use the following options to format chained method calls and make them easier to read. Note that builder method calls are always wrapped regardless of the settings for chained calls.

Item

Description

Wrap first call

Allow wrapping the first method call in chained methods.

Align when multiline

Align several method calls.

Builder methods

Specify comma-separated names (identifiers) of methods that you want to be treated as builder methods.

For example: withTitle,withYear,addAuthor,withName,withLastName,end,build

Keep builder methods indents

Keep additional indents that you insert manually intact as you reformat code.

Blank lines

Use this tab to define where and how many blank lines you want IntelliJ IDEA to retain and insert in your code after reformatting. For each type of location, specify the number of blank lines to be inserted. The results are displayed in the preview pane.

Item

Description

Keep maximum blank lines

In this area, specify the number of blank lines to be kept after reformatting in the specified locations.

Minimum blank lines

In this area, specify the number of blank lines to be present in the specified locations.

JavaDoc

Item

Description

Alignment

In this area, define the way Javadoc comments should be aligned.

  • Align parameter descriptions: select this checkbox to have parameter descriptions aligned against the longest parameter name. Otherwise, the description is separated from the corresponding parameter name by a single space.

  • Align thrown exception descriptions: select this checkbox to have thrown exception descriptions aligned against the longest exception name. Otherwise, the description is separated from the exception name by a single space.

Blank lines

In this area, define where blank lines should be inserted in Javadoc comments.

  • After description: select this checkbox to have a blank line automatically inserted after the description section of a Javadoc comment.

  • After parameter descriptions: select this checkbox to have a blank line inserted after the group of @param tags.

  • After return tag: select this checkbox to have a blank line inserted after the @return tag.

Invalid tags

In this area, define whether invalid tags should be preserved or not.

  • Keep invalid tags: select this checkbox to have the @invalidTag preserved.

  • Keep empty @param tags: select this checkbox to have @param tags without description preserved.

  • Keep empty @return tags: select this checkbox to have @return tags without description preserved.

  • Keep empty @throws tags: select this checkbox to have @throws tags without description preserved.

Other

In this area, specify additional formatting options for Javadoc comments.

  • Enable leading asterisks: start each line of a Javadoc comment with an asterisk.

  • Use @throws rather than @exception: use the @throws tag.

  • Wrap at right margin: wrap the text that exceeds the right margin to the next line.

  • Generate «<p>» on empty lines: automatically insert the </p> tag on an empty line.

  • Keep empty lines: select this checkbox to have manually added empty lines preserved.

  • Do not wrap one line comments: keep short comments on one line with the opening and closing tags.

  • Preserve line feeds: if this checkbox is not selected (by default), line feeds are not preserved on reformatting. This is convenient when comments should be formatted within the boundaries of a paragraph, to occupy minimum space.

    If this checkbox is selected, line feeds will be preserved.

  • Parameter descriptions on new line: place the description of a Javadoc parameter (if any) to a new line. It uses the indent based on the continuation indent value.

  • Indent continuation lines: indent subsequent lines in multiline comments.

Arrangement

This tab lets you define a set of rules that rearranges your code according to your preferences.

Item

Description

Grouping Rules

Use this area to set the grouping rules.

  • Keep getters and setters together

    Select this checkbox to keep getter and setter methods together. By default, this checkbox is selected.

  • Keep overridden methods together

    Select this checkbox to group the overridden methods together by class and interface. In order list, select keep order or order by name options.

  • Keep dependent methods together

    Select this checkbox to group the dependent methods together. In the order list, select depth-first order or breadth-first order options.

Matching rules

Use this area to define elements order as a list of rules, where every rule has a set of matches such as modifier or type.

  • the Add button: use this button to add a rule. The empty rule area opens.

  • the Add Section Rule button: use this button to add a section rule. The section rule lets you move methods or variables into sections that you have defined.

    For example, you can create the following section rule:

    A matching rule

    After the arrangement, methods in the class will be rearranged as specified in the created section rule and will be surrounded by comments:

    //methods start
    public void test() {}
    private int a() { return 1; }
    static void r() {}
    //methods end

  • the Remove button: use this button to remove the rule from the list.

  • the Edit button: use this button to edit an existing rule. To see this button, navigate to the rule that you want to edit and click the button. In popup that opens, modify the rule fields.

  • the Move up button the Move down button: use these buttons to move the selected rule up or down.

  • Configure matching rules: use this button to configure an alias for the matching rule. In this case, when you create an arrangement rule you can define a custom rule (alias) that would include a sequence of different rules and apply the alias to your current rule.

Empty rule

Use this area to create a new matching rule or edit an existing one. You can select from the following filters:

  • Type: use this filter to choose classes or methods for your rule.

    Note that clicking a type keyword twice negates the condition.

  • Modifier: use this filter to select the types of modifiers for the rule.

    Note that clicking a modifier keyword twice negates the condition.

  • Name: use this field to specify entry names in the rule. This filter matches only entry names, such as field names, method names, class names, and so on. The filter supports regular expressions and uses a standard syntax. The match is performed against the entire name.

  • Order: use this list to select the sorting order for the rule. This option is useful when more than one element uses the same matching rule. In this case, selecting Keep order will keep the same order as was set before the rearrangement and selecting Order by Name will sort the elements with the same matching rule by their names.

  • Aliases: this option displays aliases that were defined in the Rules Alias Definition dialog. You can remove the ones you do not need.

the Sort Alphabetically button

This icon appears when you select Order by Name from the Order list. The icon indicates that the items in this rule are sorted alphabetically.

Imports

This table lists actions to be performed when imports are optimized.

Item

Description

General

In this area, configure general import options.

Options:

  • Use single class import: import only a particular class from a package during code generation or import optimization. Otherwise, a statement that imports an entire package is inserted.

  • Use fully qualified class names: use the fully qualified name of the class to be imported during code generation or import optimization. Otherwise, a normal import statement is inserted.

  • Insert imports for inner classes: create imports for the inner classes referenced in your code.

  • Use fully qualified names in JavaDoc: use fully qualified class names in Javadocs. Otherwise, a class is imported.

  • Class count to use import with ‘*’: specify the number of classes to be imported from a single package until all statements that import a single class are substituted with a statement that imports an entire package.

  • Names count to use static import with ‘*’: in this field, specify the number of members to be imported from a single class until all statements that import a single member are substituted with a statement that imports an entire class.

JSP Imports Layout

In this area, configure how JSP import statements should be organized in your code. The introduced changes are displayed in the Preview pane below.

Options:

  • Prefer comma separated import list: select this option to import statements organized in a comma separated list.

  • Prefer one import statement per page directive: select this option to have one import statement created per line.

Packages to Use Import with ‘*’

In this area, configure a list of packages and classes to be always imported completely.

Options:

  • Static: select this checkbox, if you want to declare static import for the selected class.

  • Package: in the text fields of this column, specify the packages and classes to be always imported completely.

    Note that IntelliJ IDEA automatically adds .* at the end of the package name once you finish typing.

  • With Subpackages: select this checkbox to have all the subpackages of the selected package imported completely.

  • Add Package: click this button to add a new entry to the list of packages and classes.

  • Add Blank: click this button to add an empty separator to the list of packages and classes.

  • Remove: click this button to delete the selected package or class from the list.

Import Layout

In this area, configure how import statements should be organized in your code. You can set up certain classes to be positioned first, or last, or one after another. Imported classes will be grouped as per their packages and sorted alphabetically within a package.

Options:

  • Layout static imports separately: if this checkbox is selected, all static imports will be kept in a separate section. Otherwise, all import statements will be sorted according to the specified layout rules.

  • Static: select this checkbox, if you want to declare static import for the selected package.

  • Package: in the text fields of this column, specify the packages to be imported.

  • With Subpackages: select this checkbox to have IntelliJ IDEA apply the layout rules to all the subpackages of the selected package.

  • Add Package: click this button to add a new entry to the list of packages.

  • Add Blank: click this button to have a blank line inserted after the selected entry, which indicates that a blank line should be inserted between the corresponding import statements.

  • Move Up / Move Down: click these buttons to move a package or a blank line up or down in the list thus defining the order of import statements.

  • Remove: click this button to delete the selected package from the list.

Code Generation

Item

Description

Naming

  • Prefer longer names: Highlight the longest name in the lookup list for code completion. If disabled, highlight the shortest name.

  • Name prefix and Name suffix: Specify the prefixes and suffixes for generating suggestions for naming new symbols using the IntelliJ IDEA code generation features. For blank fields, the default name suggestions without prefixes or suffixes is used. When you add a prefix value, IntelliJ IDEA automatically converts the first letter of the suggested base name to upper case.

    For example, if the prefix for a static field is defined as s and the type of the field is Counter, then the suggested static field name will be sCounter.

Default Visibility

Select the default access level for generated fields and methods.

You can either specify it explicitly, or select Escalate to automatically raise it to a necessary level.

Final Modifier

Specify whether you want to generate local variables and parameters with the final modifier by default.

Comment Code

Use this area to configure code style for generated comments (line Ctrl+/ and block Ctrl+Shift+/):

  • Line comment at first column: start line comments (Ctrl+/) at the first column. If you disable the option, the comments will be aligned with your code.

  • Add a space at comment start: insert a space between the line comment character and the first character of the commented line.

  • Enforce on reformat: insert a space between a line comment character and the first character of a commented line in existing comments when you’re reformatting your code. Note that the first character has to be an alphanumeric symbol, otherwise the space won’t be inserted. For example, the //&Lorem ipsum comment will be ignored by the reformatter.

    This option becomes available when Add a space at comment start is enabled.

  • Block comment at first column: start block comments (Ctrl+Shift+/) at the first column. If you disable the option, the comments will be aligned with your code.

  • Add spaces around block comments: insert a space between the block comment character and the first character of the commented text.

Override Method Signature

  • Insert @Override annotation: Insert @Override annotations when you override a method.

  • Repeat synchronized modifier: Add the synchronized keyword when you override a method that is synchronized.

  • Annotations to Copy: Specify which annotations should be copied over to the method that you override.

  • Use external annotations: Prompt to specify whether you want an annotation to be stored in the source code or externally. If disabled, annotations will be added to the source code by default.

Lambda Body

If a lambda expression calls an existing method, it is preferable to refer to the method by name using a method reference. These checkboxes affect the Lambda can be replaced with method reference inspection. If enabled, the corresponding lambda expressions will be highlighted as warnings with a relevant quick-fix. If disabled, the code will not be highlighted, but an intention to replace the lambda expression with a method reference will still be available.

  • Use Class::isInstance and Class::cast when possible

    For example, replace obj1 -> obj1 instanceof Foo with Foo.class::isInstance and obj -> (Foo)obj with Foo.class::cast.

  • Replace null-check with Objects::nonNull or Objects::isNull

    For example, replace x -> x != null with Objects::nonNull.

  • Use Integer::sum, etc. when possible

    For example, replace (a, b) -> a + b with Integer::sum.

Last modified: 27 March 2023

Как можно было бы назначить ярлык для переноса слов, как это делает возвышенный текст? т. е. если строка кода слишком длинная, она должна автоматически переходить на следующую строку. wikipedia.org.org/Word_wrap

Этот код следует завернуть

person
Sayat Satybald
  
schedule
11.04.2014
  
source
источник


Ответы (11)

Я думаю, что вам нужна мягкая упаковка. Он доступен только для чтения, т.е. не изменяет символы в файле, а только переносит то, что вы видите на экране.

«мягкая Intellij ›= 14.1.4: как указано в комментариях, параметры находятся в разделе Файл › Настройки › Редактор › Общие — в подгруппе Virtual Space или Soft Wraps.

Intellij ‹ 14.1.4. Найдите в разделе Файл > Настройки > Редактор > Виртуальное пространство. По умолчанию у него нет ярлыка, но вы можете назначить его в раскладке клавиш.

AndroidStudio ›= 1.4.1: параметры находятся в разделе Файл › Настройки › Редактор › Общие в подгруппе Soft Wraps.

Вы также можете щелкнуть правой кнопкой мыши по желобу (вертикальная полоса, на которой показан номер строки) и выбрать «Использовать мягкую обертку» — спасибо Баджалу за комментарий. мягкая пленка желоба

Чтобы назначить ярлык для переключения softwrap: Найдите в разделе Файл › Настройки › Keymap, найдите softwrap, затем назначьте нужный ярлык.

person
Shorn
  
schedule
14.04.2014


[ctrl+alt+s] или Файл->Настройки, чтобы открыть диалог настроек.

Поиск стиля кода. это в настройках проекта.

В стиле кода, общая проверка

wrap when typing reaches margin

Это даст вам упаковку кода.

person
Dineshkumar
  
schedule
11.04.2014

Можно также щелкнуть правой кнопкой мыши по желобу (вертикальная полоса, где показан номер строки) и выбрать «Использовать мягкие обертки» — спасибо Баджалу за комментарий.

Это самый простой способ, и я нашел его в комментариях. Я думаю, что это должен быть ответ, чтобы все могли легко его увидеть.

person
acpuma
  
schedule
22.05.2018

В Community Edition сделайте следующее:

Файл >> Настройки >> Редактор >> Стиль кода >> Java

Перейдите на вкладку «Обертывание и скобки».

Установите параметр «Правое поле (столбцы)» с количеством столбцов, которые вы хотели бы использовать в качестве точки переноса строки. Установите для параметра «Перенос при вводе» значение ДА.

Не забудьте применить изменения, прежде чем нажать «ОК».

person
Vishal
  
schedule
07.04.2016

Чтобы обернуть текст в редакторе кода в IntelliJ IDEA 2020, выполните следующие действия:

  1. Ctrl + Shift + «A» ИЛИ Справка -> Найти действие
  2. Введите: «обернуть» в текстовое поле
  3. Переключить: Просмотр | Active Editor Soft-Wrap «ВКЛ.»

Изображение тумблера в меню

person
Noah PG
  
schedule
08.05.2020

Для версии IntelliJ IDEA: 2019.3

  1. Перейдите в Файл > Настройки

  2. Появится новое окно

  3. Выберите Редактор > Общие

Перейдите в раздел Soft Wraps, установите флажок и используйте точку с запятой в качестве разделителя, * и? в качестве подстановочных знаков добавьте нужные расширения файлов. Выберите «Применить», и все готово.

Скриншот окна настроек

person
Community
  
schedule
15.12.2019

(В Community Edition 2016+) перейдите: IntelliJ IDEA> Настройки> Редактор> Общие: выберите параметры «Использовать мягкие переносы в редакторе» и «Использовать исходный отступ строки для обернутых частей»

person
Alferd Nobel
  
schedule
01.04.2016

OS X 10.8 IntelliJ Idea 15.0.5: Меню IntelliJ IDEA/Настройки/Редактор/Общие/Мягкие обертки

person
Gyuri
  
schedule
20.04.2016

Ответ на этот вопрос:

Используйте вариант Ensure right margin is not exceeded — нижний вариант на скриншоте:

введите здесь описание изображения

person
ACV
  
schedule
06.12.2020

Это может помочь. Это решение, которое я нашел, когда пытался обернуть строки кода в редакторе кода, когда я уменьшал/увеличивал (растягивал) редактор оконного кода.

введите здесь описание изображения

person
PaulDev
  
schedule
15.08.2020

Мне помогло добавление *.java после *.adoc; потому что в Настройках, потом Общие и потом Софт-обертка эти файлы: у меня были только *.md; *.текст; *.первый; *.адок . Если после этого вы добавите ; *.java ваш длинный java-код будет перенесен на новую строку. Спасибо за экраны. Это мне очень помогло.

person
MonaRad
  
schedule
11.07.2021

Ezoicreport this ad


Last Updated: 03 Apr 2022 17:54 GMT | User: @c2cDev | Topic: Java

IDEA IntelliJ is one of the most popular IDE for Java developers around the world, by default when you look at the console, you will see that if the logs are too long then horizontal scroll is enabled and it becomes a bit hard to read the logs efficiently.

If you want to word warp the log messages in the console you can do it by clicking on the Soft-Warp button as highlighted in the below image,

Before Word-Warp IntelliJ Console Jobs

Before Word-Warp IntelliJ Console Jobs

After Word Wrap IntelliJ Console Logs

After Word Wrap IntelliJ Console Logs

I have recently started to use IntelliJ Idea as my text editor and integrated it into my creative process.

As I am a software developer, IntelliJ IDE is, for me, a must. IDE is in front of me opened all the time. Therefore it is a chance for me to write a lot of content in the IDE. It is a better choice to use IDE instead of switching to another text editor or using another means of word processing.

Since I am also aiming to work on several articles or documents simultaneously, every decrease in ambiguity and complexity counts towards faster results. The creative process is not possible to automatize. But what it is possible to automatize are redundant tasks during text handling and editing.

Why turn IntelliJ Idea IDE into your word processor?

First of all, IntelliJ Idea IDE already comes in its 2020 version with very, very good support for English vocabulary. So writing in English in IDE was never easier than now.

Plus, when implementing the advantage of multiple IntelliJ shortcuts, the word processing is swift. Especially if you write your text in .html, .adoc or .md format.

Overall, IntelliJ IDE comes in all versions with Git support, which is an additional advantage against traditional word processors. You can easily version your articles’ state and keep a history of your edits in one place. Article versioning is a feature that is available only in very advanced mode in cloud SaaS.

However, what I have found very tedious was text formatting in IntelliJ. As expected, I was using IntelliJ Idea IDE for coding, mostly Java, and thus the text was supposed to be wrapped automatically after 120 characters. When I then copied my articles to other word processors in my pipelines, such as Microsoft Word or Grammarly, I always needed painfully deleted every single break line to make a single continuous line of text. That was also one of the most common mistakes I had after publishing articles through WordPress – linebreaks were always in places where they should not be.

After enough time spent doing this pointless work, fixing many wrong break lines, I have decided to end it and figure out how to speed up the process. Because every second I spend editing an article is second, I could use it towards another article’s creative process.

How to turn IntelliJ Idea into text editor?

First of all, go to Settings > Editor > General and check all checkboxes in Soft Wraps section.

IntelliJ soft-wrap checkboxes_in_general editor settings

Then go to Settings > Code Style and select Scheme Project. Here unselect the checkbox “Wrap on typing”.

IntelliJ soft-wrap editor code style

I would recommend this change be saved under the current project scheme, not under the IDE scheme. If you are using the same IntelliJ for coding, wrapping will conflict with your code clarity if you save the change under the IDE scheme.

Hit Apply button to apply all the changes.

Initialize soft-wrap in IntelliJ code editor

In the active editor tab, on the left side of the text line panel, after the right-click, there is an option soft-wrap to initiate the wrapping. Soft-wrap is not initialized automatically on every new file open. Therefore you will need to initialize soft-wrap on every new file open.

Tip for shortcut

When you open a new file, the text is, by default, unwrapped. You can either right-click on the newly opened line meter on the left side and hit Soft-Wrap from the menu option. Or you can set up a special shortcut for soft-wrapping, while the shortcut is not set by default.

IntelliJ soft-wrap - custom shortcut

To set up your shortcut, go to File > Settings > Keymap and search for “Soft-Wrap” in Main Menu > View > Active Editor. Add to action key shortcut. I personally use Alt + P key shortcut. That is not a conflicting key shortcut with keys combinations easy to remember.

These are my must-have settings tweaks for IntelliJ IDEA, mixed with some useful tips. However, I recommend going through all the preferences in the Settings Dialog yourself. You probably don’t even know about some problems the IDE can solve for you when adjusted correctly.

Check out my config-files for more IDEA settings.

Table of contents:

How to change settings

There are several ways to change settings in IntelliJ IDEA.

To open the Settings Dialog, select «File»«Settings…» or use the Ctrl + Alt + S shortcut. You can then navigate through the settings in the left panel. Speed up the search by using quick find — simply type part of the setting name.

Settings Dialog — Quick Find

Sometimes you don’t even need to open the settings dialog. Press Ctrl + Shift + A and type the setting name. If it’s a checkbox option, you can press Return to toggle the setting — effective immediately!

Toggle settings

Finally, some settings are only applied to the current project, e.g. the JavaScript language level. To customize default project settings, go to «File»«Other Settings»«Default settings…».

Show current IDEA memory usage in the status bar

☑ Appearance & Behavior → Appearance → Show memory indicator

Activate this option to show the current IDE heap level and memory usage in the lower right corner of the status bar. Additionally, you can click on this widget to run the garbage collector.

IntelliJ Memory Indicator

For big projects you might want to increase the maximum heap memory size. Open IDE_HOMEidea[64][.exe].vmoptions and adjust the -Xmx value.

Adjust for widescreen

☑ Appearance & Behavior → Appearance → Widescreen tool window layout

If you have a widescreen monitor, you should enable this setting. Basically, this will give you more space for your side panels.

Notice: those screenshots are highly exaggerated to demonstrate the difference — usually, you wouldn’t open so many panels. If you do, consider the Ctrl + Shift + F12 shortcut to toggle the panels and maximize the editor view.

Widescreen turned off
Widescreen turned on

Zoom with the mouse wheel

☑ Editor → General → Change font size (zoom) with Ctrl+Mouse Wheel

That’s a feature known from most other text editors and browsers, but it’s disabled by default. Enable this option to zoom using Ctrl + Mouse Wheel. Since IDEA 2021.3, you can decide whether all tabs should be affected.

Show line numbers on the editor gutter

☑ Editor → General → Appearance → Show line numbers

That’s self-explanatory. Additionally, press Ctrl + G to navigate to a line number.

Wrap long lines

☑ Editor > General > Use soft wraps in editor ☑ Editor > General > (Console >) Use soft wraps in console Editor > General > Use custom soft wraps indent/additional shift: 1

If you don’t like scrolling long lines horizontally, activate word wrapping. I also like to add a small indent. When you put the cursor on a wrapped line, IntelliJ will additionally insert small arrow symbols to highlight the wraps.

Wrap long lines

Improve tab appearance

☑ Editor → General → Editor Tabs → Hide file extension in editor tabs ☐ Editor → General → Editor Tabs → Show «close» button on editor tabs

By hiding both file extensions and close icons you will gain a lot of free space in the editor tab panel. File icons are enough to infer the file types, and you are still able to close tabs by pressing the middle mouse key or Ctrl + F4.

Tabs with extension and close icon
Smaller tabs

Hadi Hariri, who gives great talks about IntelliJ Tips and Tricks, recommends turning off editor tabs completely. Instead, use Ctrl + E to switch between recent files and Ctrl + Shift + E to switch between recently edited files.

Sort debugger fields alphabetically

☑ Build, Execution, Deployment → Debugger → Data Views → Sort alphabetically

By default, debugger variables are listed in the order in which they were defined. I find this makes it harder to find the right values.

Bonus tip: you can focus any list/tree panel (like debugger variables, or the project view) and search for a value by simply starting to type. If multiple values match the search string, use and keys to step through them. In this example I typed mo, so I can toggle the selection between module and mongoose:

Debugger variables sorted alphabetically

Improve Java imports

☑ Editor → General → Auto Import → Add unambiguous imports on the fly

This will add import statements automatically, if there is only one class in the classpath with the exact name.

Editor → General → Auto Import → Exclude from Import and Completion

Usually, if you want to use the List class, IntelliJ won’t import it automatically, even with the previous option enabled. That’s because there are two List classes in the classpath: java.util.List and java.awt.List. Fortunately, you can exclude classes and packages from import assistance and code completion. It works exactly like Type Filters in Eclipse. I usually exclude:

  • com.sun
  • sun
  • java.awt.List
  • java.sql.Date

and some project specific packages.

You don’t need to add those entries manually. Whenever IntelliJ suggests multiple classes to import, press and select the class or package to exclude.

Exclude import

That’s a new feature in IntelliJ IDEA 15. Finally, we are able to remove unwanted tool window buttons. Just right click a sidebar button and select Remove from sidebar. You can restore a hidden tool window with View → Tool Windows.

Remove sidebar panel

Use a custom terminal shell

☑ Tools → Terminal → Shell path

IDEA comes with a handy terminal panel (Alt + F12). However, using the default Windows command prompt can sometimes be annoying. Fortunately, you can use a more useful shell within IntelliJ IDEA, like the Git Bash (by default under C:Program FilesGitbinbash.exe).

You can customize the terminal font and colors here:

☑ Editor → Colors & Fonts → Console Font/Colors

Вопрос:

Могу ли я включить перенос слов в IntelliJ IDEA глобально, а не только для текущего проекта? Кроме того, могу ли я избавиться от переписывания длинных строк текста в виде конкатенации? Я обернулся в Файл → Настройки → Стиль кода (правое поле (столбцы)… обертывание при вводе текста, но все же, когда я использую System.out.println(“Некоторая длинная длинная строка”), он, похоже, конкатенируется на во-первых, и я должен изменить это.

Лучший ответ:

AFAIK, настройки форматирования кода организованы в схемах, а не для текущего проекта.

Откройте “Настройки” -Dialog, перейдите в “Редактор” → “Стиль кода” и активируйте “Wrap on typing”. Длинные строки будут завернуты во время ввода. Если вы вставляете длинную строку из буфера обмена, обертка выполняется после нажатия Ctrl Alt L (Windows).

enter image description here

Как можно было бы назначить ярлык для переноса слов, как это делает возвышенный текст? то есть, если строка кода слишком длинная, она должна автоматически переноситься на следующую строку. http://e n.wikipedia.org/wiki/Word_wrap

Этот код должен быть упакован

2014-04-11 05:53

13

ответов

Решение

I think «soft wrap» might be what you’re after. It’s read-only, ie does not change the characters in the file, it only wraps what you see on screen.

Intellij >= 14.1.4: As pointed out by looper in the comments, the options are under File > Settings > Editor > General — under the Virtual Space or Soft Wraps sub-group.

Intellij < 14.1.4: Look under File > Settings > Editor > Virtual Space. It doesn’t have a shortcut by default, but you can assign one in the keymap.

AndroidStudio >= 1.4.1: the options are under File > Settings > Editor > General — under the Soft Wraps sub-group.

You can also right click the gutter (the vertical bar where line number is shown) and select «Use Soft wraps» — thanks to Bajal for comment.

2014-04-14 23:34

[Ctrl+ Alt+ S] или Файл-> настройки, чтобы открыть диалог настроек.

Поиск стиля кода. его в настройках проекта.

В стиле кода, общая проверка

wrap when typing reaches margin

Это даст вам упаковку кода.

2014-04-11 08:53

Можно также щелкнуть правой кнопкой мыши по желобу (вертикальная полоса, где показан номер строки) и выбрать «Использовать мягкие переносы» — спасибо Баджалу за комментарий.

Это самый простой способ, и я нашел его в комментариях. Я думаю, что это должен быть ответ, чтобы каждый мог видеть это легко.

2018-05-22 13:55

Чтобы обернуть текст в редакторе кода в IntelliJ IDEA 2020, выполните следующие действия:

  1. Crtl + Shift + «A» ИЛИ Справка -> Найти действие
  2. Введите: «обернуть» в текстовое поле
  3. Переключить: Просмотр | Активный редактор Soft-Wrap «ВКЛ»

2020-05-08 06:42

В Community Edition выполните следующие действия:

Файл >> Настройки >> Редактор >> Стиль кода >> Java

Перейдите на вкладку «Упаковка и брекеты».

Установите опцию «Правое поле (столбцы)» с количеством столбцов, которые вы хотите использовать в качестве точки переноса строк. Установите «Wrap при наборе текста» на ДА.

Не забудьте применить изменения, прежде чем нажать Ok.

2016-04-07 16:22

Для версии IntelliJ IDEA: 2019.3

  1. Перейдите в Файл> Настройки

  2. Появится новое окно

  3. Выберите Editor > General

Перейдите в раздел Soft Wraps, установите флажок и используйте точку с запятой в качестве разделителя, * и? в качестве подстановочных знаков добавьте желаемые расширения файлов. Выберите Применить, и все готово.

2019-12-15 12:44

Ответ на этот вопрос:

Воспользуйтесь опцией
Ensure right margin is not exceeded — нижний вариант на скриншоте:

2020-12-06 03:01

Щелкните правой кнопкой мыши в любом месте на панели количества строк и выберите «мягкий перенос».

Или вы можете просто перейти в View -> Active Editor -> Soft-Wrap.

2022-06-20 03:13

(В Community Edition 2016+): IntelliJ IDEA> «Установки»> «Редактор»> «Общие»: выберите параметры «Использовать мягкие переносы в редакторе» и «Использовать отступ строки оригинала для обернутых частей»

2016-04-01 23:20

OS X 10.8 IntelliJ Idea 15.0.5:
IntelliJ IDEA Меню / Настройки / Редактор / Общие / Мягкие упаковки

2016-04-20 05:18

Контекстное меню желоба имеет опцию мягкого обтекания. Щелкните правой кнопкой мыши на желобе, расположенном в крайнем левом углу редактора, чтобы открыть меню.

2022-03-29 23:12

Мне помогло добавление «* .java» после «* .adoc;» потому что в «Настройках», затем «Общие», а затем «Мягко оберните эти файлы:» у меня были только «* .md; *.txt; *.rst; * .adoc». Если после этого вы добавите «; * .java», ваш длинный java-код будет перенесен в новую строку. Спасибо за экраны. Это мне очень помогло.

2021-07-12 01:50

Это может помочь. Это решение, которое я нашел, когда пытался обернуть строки кода в редакторе кода, когда я уменьшал / увеличивал (растягивал) редактор оконного кода.

View post on imgur.com

2020-08-15 20:20

I solved this by following this guide. It was meant for PHPStorm but works for IntelliJ IDEA as well (probably WebStorm too!). It was very simple, actually. A basic recap:

  1. Saved the following PHP code in my project root. It’s basically just a PHPDoc comment:
    <?php  die('This file is not really here!');

    /**
     * ------------- DO NOT UPLOAD THIS FILE TO LIVE SERVER ---------------------
     *
     * Implements code completion for CodeIgniter in phpStorm
     * phpStorm indexes all class constructs, so if this file is in the project it will be loaded.
     * -------------------------------------------------------------------
     * Drop the following file into a CI project in phpStorm
     * You can put it in the project root and phpStorm will load it.
     * (If phpStorm doesn't load it, try closing the project and re-opening it)
     * 
     * Under system/core/
     * Right click on Controller.php and set Mark as Plain Text
     * Do the same for Model.php
     * -------------------------------------------------------------------
     * This way there is no editing of CI core files for this simple layer of code completion.
     *
     * PHP version 5
     *
     * LICENSE: GPL http://www.gnu.org/copyleft/gpl.html
     *
     * Created 1/28/12, 11:06 PM
     *
     * @category
     * @package    CodeIgniter CI_phpStorm.php
     * @author     Jeff Behnke
     * @copyright  2009-11 Valid-Webs.com
     * @license    GPL http://www.gnu.org/copyleft/gpl.html
     * @version    2012.01.28
     */

    /**
     * @property CI_DB_active_record $db              This is the platform-independent base Active Record implementation class.
     * @property CI_DB_forge $dbforge                 Database Utility Class
     * @property CI_Benchmark $benchmark              This class enables you to mark points and calculate the time difference between them.
Memory consumption can also be displayed. * @property CI_Calendar $calendar This class enables the creation of calendars * @property CI_Cart $cart Shopping Cart Class * @property CI_Config $config This class contains functions that enable config files to be managed * @property CI_Controller $controller This class object is the super class that every library in.
CodeIgniter will be assigned to. * @property CI_Email $email Permits email to be sent using Mail, Sendmail, or SMTP. * @property CI_Encrypt $encrypt Provides two-way keyed encoding using XOR Hashing and Mcrypt * @property CI_Exceptions $exceptions Exceptions Class * @property CI_Form_validation $form_validation Form Validation Class * @property CI_Ftp $ftp FTP Class * @property CI_Hooks $hooks Provides a mechanism to extend the base system without hacking. * @property CI_Image_lib $image_lib Image Manipulation class * @property CI_Input $input Pre-processes global input data for security * @property CI_Lang $lang Language Class * @property CI_Loader $load Loads views and files * @property CI_Log $log Logging Class * @property CI_Model $model CodeIgniter Model Class * @property CI_Output $output Responsible for sending final output to browser * @property CI_Pagination $pagination Pagination Class * @property CI_Parser $parser Parses pseudo-variables contained in the specified template view,
replacing them with the data in the second param * @property CI_Profiler $profiler This class enables you to display benchmark, query, and other data
in order to help with debugging and optimization. * @property CI_Router $router Parses URIs and determines routing * @property CI_Session $session Session Class * @property CI_Sha1 $sha1 Provides 160 bit hashing using The Secure Hash Algorithm * @property CI_Table $table HTML table generation
Lets you create tables manually or from database result objects, or arrays. * @property CI_Trackback $trackback Trackback Sending/Receiving Class * @property CI_Typography $typography Typography Class * @property CI_Unit_test $unit_test Simple testing class * @property CI_Upload $upload File Uploading Class * @property CI_URI $uri Parses URIs and determines routing * @property CI_User_agent $user_agent Identifies the platform, browser, robot, or mobile devise of the browsing agent * @property CI_Validation $validation //dead * @property CI_Xmlrpc $xmlrpc XML-RPC request handler class * @property CI_Xmlrpcs $xmlrpcs XML-RPC server class * @property CI_Zip $zip Zip Compression Class * @property CI_Javascript $javascript Javascript Class * @property CI_Jquery $jquery Jquery Class * @property CI_Utf8 $utf8 Provides support for UTF-8 environments * @property CI_Security $security Security Class, xss, csrf, etc... */ class CI_Controller{} /** * @property CI_DB_active_record $db This is the platform-independent base Active Record implementation class. * @property CI_DB_forge $dbforge Database Utility Class * @property CI_Benchmark $benchmark This class enables you to mark points and calculate the time difference between them.
Memory consumption can also be displayed. * @property CI_Calendar $calendar This class enables the creation of calendars * @property CI_Cart $cart Shopping Cart Class * @property CI_Config $config This class contains functions that enable config files to be managed * @property CI_Controller $controller This class object is the super class that every library in.
CodeIgniter will be assigned to. * @property CI_Email $email Permits email to be sent using Mail, Sendmail, or SMTP. * @property CI_Encrypt $encrypt Provides two-way keyed encoding using XOR Hashing and Mcrypt * @property CI_Exceptions $exceptions Exceptions Class * @property CI_Form_validation $form_validation Form Validation Class * @property CI_Ftp $ftp FTP Class * @property CI_Hooks $hooks Provides a mechanism to extend the base system without hacking. * @property CI_Image_lib $image_lib Image Manipulation class * @property CI_Input $input Pre-processes global input data for security * @property CI_Lang $lang Language Class * @property CI_Loader $load Loads views and files * @property CI_Log $log Logging Class * @property CI_Model $model CodeIgniter Model Class * @property CI_Output $output Responsible for sending final output to browser * @property CI_Pagination $pagination Pagination Class * @property CI_Parser $parser Parses pseudo-variables contained in the specified template view,
replacing them with the data in the second param * @property CI_Profiler $profiler This class enables you to display benchmark, query, and other data
in order to help with debugging and optimization. * @property CI_Router $router Parses URIs and determines routing * @property CI_Session $session Session Class * @property CI_Sha1 $sha1 Provides 160 bit hashing using The Secure Hash Algorithm * @property CI_Table $table HTML table generation
Lets you create tables manually or from database result objects, or arrays. * @property CI_Trackback $trackback Trackback Sending/Receiving Class * @property CI_Typography $typography Typography Class * @property CI_Unit_test $unit_test Simple testing class * @property CI_Upload $upload File Uploading Class * @property CI_URI $uri Parses URIs and determines routing * @property CI_User_agent $user_agent Identifies the platform, browser, robot, or mobile devise of the browsing agent * @property CI_Validation $validation //dead * @property CI_Xmlrpc $xmlrpc XML-RPC request handler class * @property CI_Xmlrpcs $xmlrpcs XML-RPC server class * @property CI_Zip $zip Zip Compression Class * @property CI_Javascript $javascript Javascript Class * @property CI_Jquery $jquery Jquery Class * @property CI_Utf8 $utf8 Provides support for UTF-8 environments * @property CI_Security $security Security Class, xss, csrf, etc... */ class CI_Model{}

2. Found /system/core/controller.php and /system/core/model.php inside of IntelliJ IDEA and right clicked->Mark as Plain Text.

3. Done! It works great, no more false errors, and code completion!

Like this post? Please share to your friends:
  • Word wrap in table latex
  • Word wrap in phpstorm
  • Word wrap in english
  • Word wrap in eclipse
  • Word wrap css break all