How can I permanently enable line numbers in IntelliJ IDEA?
IntelliJ 14.X Onwards
From version 14.0 onwards, the path to the setting dialog is slightly different, a General submenu has been added between Editor and Appearance as shown below
IntelliJ 8.1.2 - 13.X
From IntelliJ 8.1.2 onwards, this option is in File | Settings1. Within the IDE Settings section of that dialog, you'll find it under Editor | Appearance.
On a Mac, these are named IntelliJ IDEA | Preferences...
The question is obviously well answered already, but since IJ 13 you can enable line numbers in 2 seconds flat:
Press shift twice
Type "line number"
The option shows in the menu and press enter to enable/disable.
Et voila ;)
NOT a solution, rather a TEMPORARY solution which only works only for the current editor and current session:
Simply right click on the place where the line-numbers should be, and there you'll see a small menu.
then, mark the "Show Line Numbers" option.
Please note that this only works on a per-file basis, however. Enjoy.
In Intellij 13 the layout has changed, the Settings button can only be found in File -> Settings and not in the toolbars, and from there you follow the same steps: Editor -> Appearance -> Show line numbers, or search for Line numbers in the Settings search input.
Android Studio 1.3.2 and on, IntelliJ 15 and on
Global configuration
File -> Settings -> Editor -> General -> Appearance -> Show line numbers
Current editor configuration
First way: View -> Active Editor -> Show Line Numbers (this option will only be available if you previously have clicked into a file of the active editor)
Second way: Right click on the small area between the project's structure and the active editor (that is, the one that you can set breakpoints) -> Show Line Numbers.
For InteliJ IDEA 11.0 and above
Goto File --> Settings in the Settings window Editor --> Appearance
and tick Show line numbers check box.
IntelliJ 14 (Ubuntu):
See: how-do-i-turn-on-line-numbers-permanently-in-intellij-14
Permanently:
File > Settings > Editor > General > Appearance > show line numbers
For current Editor:
View > Active Editor > Show Line Numbers
IntelliJ IDEA 15
5 approaches
Global change
File > Settings... > Editor > General > Appearance > Show line numbers
Hit Shift twice > write "line numbers" > Show Line Numbers (that one that has the toggle) > change the toggle to ON
Change for the Active Editor
Right click on the left side bar > Show Line Numbers
Hit Shift twice > write "line" > Show Line Numbers (the line doesn't have the toggle)
Ctrl + Shift + A > write "Show line" > Active Editor: Show Line Numbers > change the toggle to ON
Ok in intelliJ 14 Ultimate using the Mac version this is it.
IntelliJ Idea > Preferences > Editor > General > Appearance > Show Line Numbers
On IntelliJ 12 on MAC OSX, I had a hard time finding it. The search wouldn't show me the way for some reason. Go to Preferences and under IDE Settings, Editor, Appearance and select 'Show line numbers'
Android Studio
Go to Android Studio => Preferences => Editor => General => Appearance => set Checked "Show line numbers"
I just hit this with IdeaVim plugin installed, where even if I set Show Line Numbers, it continued to revert to hiding them.
The (forehead-slapping-worthy) solution was:
:set nu
I add this response for IntelliJ IDEA 2018.2 - Ultimate.
Using menu
IntelliJ Idea > Preferences > Editor > General > Appearance > Show Line Numbers
Using Shortcuts - First way
For Windows : Ctrl+Shift+a
For Mac : Cmd+shift+a
Using Shortcuts - Seconde way
Touch Shift twice
These three methods exist since the last 4 versions of Intellij and I think they remain valid for a long time.
1st way: Go to View => Active Editor => show line numbers
2nd way Go to Android Studio => Preferences => Editor=> Appearance => set Checked "Show Line Numbers"
For 9.0.4
File > Settings
In the tree view group
------------IDE Settings ---------
Click the Editor [+]
Select Appearance... Its there.
On Mac Intellij 12.1.2 there is no File-Settings:
There is an application-name menu item to the left of "File" with a "preferences" menu item:
and within that is the "Settings" dialog shown by the Windows Intellij.
In IntelliJ 14 it has moved again somewhat down the menu.
Now we have it unter Editor -> General -> Appearance
Just an update for Android Studio 1.5.1 on Windows:
Go to File -> Settings -> follow picture
On IntelliJ IDEA 2016.1.2
Go to Settings > Editor > General > Appearance
then check the Show Line number option
IntelliJ 2019 community edition has line number by default. If you want to show or hide line numbers, go to the following settings to change the appearance.
go to → File → Setting → Editor → General → Appearance → [Check] Show line numbers
For IntelliJ 20.1 or above, on Mac OSX:
IntelliJ IDEA -> Editor -> General -> Appearance -> Show line numbers
Point to be noted: Always look for Editor
For shortcut:
⌘ + ⇧ + A (command + shift + A)
type
and click on the pop up to turn on Show line numbers and you are good to go.
Related
How to make line number visible in PhpStorm 2016.1?
I can't find setting in preferences.
Use CMD+SHIFT+A (on Mac) to search for actions across the IDE, including the preference pane. In this instance, typing "Line Numbers" into the search box takes you right to the preference pane for that option, with it highlighted nicely for you (http://c.hock.in/17c45d.png). This works for any settings you can't find, or want to find quickly.
Preferences if your are on Mac | Editor --> (General) --> Appearance --> Show line numbers.
File->Setting->Editor->Appearance->show line numbers for Windows users
1.
PhpStorm 2016.1 for Active Editor only
Main Menu:
View -> Active Editor -> Show Line Numbers
===========================================
2.
PhpStorm 2016.1 for all tabs
Main Menu
File -> Settings:
How can I disable (or hide) this part in IntelliJ idea ?
Go to File -> Settings -> Editor -> General -> Code Folding
Uncheck Show code folding outline.
For IntelliJ 15+ with default keyboard bindings
Press cmd+shift+A on a mac or ctrl+shift+A on windows, to search for an action, and type code folding. This pops up a menu with an option of 'Show code folding outline' and on the right of it is an off/on switch. You can change this with enter or just click on it.
The settings dialog is old-hat these days.
Not sure what OP is asking, if one wishes to just hide the folding outline, then the #Phiter answer is correct.
However if one wishes to disable the actual code folding just uncheck boxes below the label Collapse by default.
BEFORE:
AFTER:
To disable the folding icons and folding completely uncheck all checkboxes as depicted here:
Color
If you want to be able to fold code without seeing the ugly Tear Line then set...
Editor > Color Scheme > General > Editor > Tear line to same as
Editor > Color Scheme > General > Editor > Gutter background
Then
Editor > Color Scheme > General > Editor > Tear selection to a different color
This should make it invisible, but still accessible when needed.
Code folding settings
These can be found here.
File > Settings > Editor > General > Code Folding
These settings should be enough to get the look and functionality you want. I personally like it to be invisible but I like to fold some HTML every now and then, but never folded by default. Jetbrains, of course, have a setting for that which you can find with the paths above.
File > Settings > Keymap
Find Hot Keys (comment)
Add new combination Hot Key for comment
enter image description here
recently a gray vertical line appeared in about the middle of the editor pane of my IntelliJIdea Community Edition 13.1.4 probably due to some manipulations with the settings that I cannot remember. I cannot find how to get rid of it, which is annoying. Who can help?
Thanks.
Updated answer:
Go to Preferences → Editor → General → Appearance and uncheck Show hard wrap and visual guides.
Original answer:
Go to Settings → Editor → General → Appearance and uncheck Show Right Margin.
You can also configure where the right margin is in the code style settings.
It is called 'Show hard wrap guide' now,
located in Editor > General > Appearance
In new versions of JetBrains IDEs, Hence, After 2017, you should search show hard wrap guide. see below screenshot:
It's inside of Editor > General > Appearance
In mac Command+Shift+A .. Search for "show right margin" . Press enter to turn it off. Booom
Go to settings and type line separator in search and hard wrap it to 180
For PyCharm 2017 and aboce it was moved, but can still be done by:
Editor > Color Scheme > General. Then in the new control to the right, open Editor > Guides > Hard wrap guide, and uncheck the checkbox for "Foreground".
2018-10-31
Settings -> Editor -> Code Style
you can find 'Hard wrap at [value] columns'.
230 columns is good to me.
Windows JetBrains Rider 2022:
File->Settings->Editor->General->Appearance
Uncheck "Show hard wrap and visual guides (configured in Code Style options)"
On windows, for IntelliJ IDEA 2021.3 (Community Edition):
File
-> Settings
-> Editor
-> General
-> Appearance
-> Uncheck "Show indent guides"
In version IntelliJ IDEA 2022.3 (Community Edition)
Build #IC-223.7571.182, built on November 29, 2022
You can browse to:
File -> Settings -> Editor -> General -> Appearance
Uncheck "Show hard wrap and visual guides (configured in Code Style options)
Or optionally if you really don't want to browse this long, just search on top left search option as "Hard wrap" or "visual guides".
How can I use tabs instead of multiple spaces for indentation in IntelliJ IDEA 11.0?
I have "Use tab character" checked under "Code Style" > "General" > "Default Indent Options". And also tried to have "Smart tabs" checked, but it doesn't help.
From the documentation:
If this check box is selected, tab characters are used:
On pressing the Tab key
For indentation
For code reformatting
Otherwise, spaces are used instead of tabs.
File > Settings > Editor > Code Style > Java > Tabs and Indents > Use tab character
Substitute weapon of choice for Java as required.
IntelliJ IDEA 15
Only for the current file
You have the following options:
Ctrl + Shift + A > write "tabs" > double click on "To Tabs"
If you want to convert tabs to spaces, you can write "spaces", then choose "To Spaces".
Edit > Convert Indents > To Tabs
To convert tabs to spaces, you can chose "To Spaces" from the same place.
For all files
The paths in the other answers were changed a little:
File > Settings... > Editor > Code Style > Java > Tabs and Indents > Use tab character
File > Other Settings > Default Settings... > Editor > Code Style > Java > Tabs and Indents > Use tab character
File > Settings... > Editor > Code Style > Detect and use existing file indents for editing
File > Other Settings > Default Settings... > Editor > Code Style > Detect and use existing file indents for editing
It seems that it doesn't matter if you check/uncheck the box from Settings... or from Other Settings > Default Settings..., because the change from one window will be available in the other window.
The changes above will be applied for the new files, but if you want to change spaces to tabs in an existing file, then you should format the file by pressing Ctrl + Alt + L.
I have started using IntelliJ IDEA Community Edition version 12.1.3 and I found the setting in the following place: -
File > Other Settings > Default Settings > {choose from Code Style dropdown}
For anyone not able to get this, another thing you need to uncheck the following as well
Preferences > Editor > Code Style
[] Enable EditorConfig support
EditorConfig may override the IDE code style settings
My IntelliJ version 15.0.4
Another useful option in IDEA to switch off or keep checked if you really need that:
Preferences -> Code Style -> Detect and use existing file indents for editing
if your team is going to switch to tab formatting with existing code written with spaces, uncheck that
Have you tried .editorconfig? You can create this file in the root of your project and configure indentation for different file types. Your code will be automatically formatted. Here's the example:
# top-most EditorConfig file
root = true
# matches all files
[*]
indent_style = tab
indent_size = 4
# only json
[*.json]
indent_style = space
indent_size = 2
My Intellij version is 13.4.1
Intellij IDEA->Perference->Code Style(Project Setting)
To expand on #Dmitiri Algazin 's answer: settings for individual languages are overridden by the general setting
Preferences -> Code Style -> Detect and use existing file indents for editing
So if you are wondering why your new settings are being ignored after changing your settings for a specific language, there is a chance this checkbox is ticked.
As a side note; changing any default settings automamagically creates a settings profile clone (i.e. Default(1)) which I assume is in place so that the default IDE settings are never overwritten.
It is a little confusing at first, really, whether editing Default settings or Project Settings is going to have any effect on your project, since you can select Default from the drop down menu and then edit from there.
If you don't want to keep seeing random clones of Default populating your settings profiles, edit the Project Settings directly.
For those who are having trouble indenting phpstorm here I have a tip and I hope they help ...
First you have to go to file-> settings-> keymap-> select-> windows.
If they are on the windows machine. If you are on mac and choose macos.
I remember seeing in either IntelliJ or Eclipse the setting to reformat (cleanup) files whenever they are saved. How do I find it (didn't find it in the settings)
This solution worked better for me:
Make a macro (I used Organize Imports, Format Code, Save All)
Assign it a keystroke (I overrode Ctrl+S)
Note: You will have to check the box "Do not show this message again" the first time for the organized imports, but it works as expected after that.
Step-by-step for IntelliJ 10.0:
Code -> "Optimize Imports...", if a dialogue box appears, check the box that says "Do not show this message again.", then click "Run".
Tools -> "Start Macro Recording"
Code -> "Optimize Imports..."
Code -> "Reformat Code..."
File -> "Save all"
Tools -> "Stop Macro Recording"
Name the macro (something like "formatted save")
In File -> Settings -> Keymap, select your macro located at "Main Menu -> Tools -> "formatted save"
Click "Add Keyboard Shortcut", then perform the keystroke you want. If you choose Ctrl+S like me, it will ask you what to do with the previous Ctrl+S shortcut. Remove it. You can always reassign it later if you want.
Enjoy!
For IntelliJ 11, replace
step 2. with: Edit -> Macros -> "Start Macro Recording"
step 6. with: Edit -> Macros -> "Stop Macro Recording"
Everything else remains the same.
IntelliJ 12
8. The Preferences contain the Keymap settings. Use the input field to filter the content, as shown in the screenshot.
I suggest the save actions plugin. It also supports optimize imports and rearrange code.
Works well in combination with the eclipse formatter plugin.
Search and activate the plugin:
Configure it:
Edit: it seems like it the recent version of Intellij the save action plugin is triggered by the automatic Intellij save. This can be quite annoying when it hits while still editing.
This github issue of the plugin gives a hint to some possible solutions:
https://github.com/dubreuia/intellij-plugin-save-actions/issues/63
I actually tried to assign reformat to Ctrl+S and it worked fine - saving is done automatically now.
Below is Neil's answer updated.
IntelliJ 13 Steps:
Code -> Reformat Code
Edit -> Macros -> Start Macro Recording
Code -> Reformat Code
File -> Save all
Edit -> Macros -> Stop Macro Recording
Name the macro (something like "formatted save")
File -> Settings -> Keymap
Right click on the macro. Add Keyboard Shortcut. Set the keyboard shortcut to Control + S.
IntelliJ will inform you of a hotkey conflict. Select "remove" to remove other assignments.
I set it to automatically clean up on check-in, which is usually good enough for me. If something is too ugly, I'll just hit the shortcut (Ctrl-Alt-L, Return). And I see they have an option for auto-formatting pasted code, although I've never used that.
If you have InteliJ Idea Community 2018.2 and above the steps are as fallows:
In the top menu you click: Edit > Macros > Start Macro Recordings
(you'll see a window lower right corner of your screen confirming
that macros are being recorded)
In the top menu you click: Code >
Reformat Code (you'll see the option being selected in the lower
right corner)
In the top menu you click: Code > Optimize Imports
(you'll see the option being selected in the lower right corner)
In the top menu you click: File > Save All
In the top menu you click: Edit > Macros > Stop Macro Recording
You name the macro: "Format Code, Organize Imports, Save"
In the top menu you clock: File > Settings. In the settings windows you click Keymap
In the search box on the right you search "save". You'll find Save All (Ctrl+S). Right click on it and select "Remove Ctrl+S"
Remove your search text from the box, press on the Collapse All button (Second button from the top left)
Go to macros, press on the arrow to expand your macros, find your saved macro and right click on it. Select Add Keyboard Shortcut, and press Ctrl+S and okay.
Restart your IDE and try it.
I know what you're going to say, the guys before me wrote the same thing. But I got confused using the steps above this post, and I wanted to write a dumb down version for people who have the latest version of the IDE.
Ctrl + Alt + L is format file (includes the two below)
Ctrl + Alt + O is optimize imports
Ctrl + Alt + I will fix indentation on a particular line
I usually run Ctrl + Alt + L a few times before committing my work. I'd rather it do the cleanup/reformatting at my command instead of automatically.
Rejoice! In IDEA 2021.2 there is finally "File->Settings->Tools->Actions on Save" where you can select "Reformat code", "Optimize imports", "Rearrange code", "Run code cleanup", "Run eslint --fix" etc.
If you're developing in Flutter, there's a new experimental option as of 5/1/2018 that allows you to format code on save.
I wound up rebinding the Reformat code... action to Ctrl-S, replacing the default binding for Save All.
It may sound crazy at first, but IntelliJ seems to save on virtually every action: running tests, building the project, even when closing an editor tab. I have a habit of hitting Ctrl-S pretty often, so this actually works quite well for me. It's certainly easier to type than the default bind for reformatting.
IntellIJ 14 && 15: When you are checking in code in Commit changes dialog, tick the Reformat code checkbox, then IntelliJ will reformatting all the code that you are checking in.
Source: www.udemy.com/intellij-idea-secrets-double-your-coding-speed-in-2-hours
For PyCharm/IntelliJ IDEA:
Install black.
$ pip install black
Locate your black installation folder.
On macOS / Linux / BSD:
$ which black
/usr/local/bin/black # possible location
On Windows:
$ where black
%LocalAppData%\Programs\Python\Python36-32\Scripts\black.exe # possible location
Note that if you are using a virtual environment detected by PyCharm, this is an unneeded step. In this case the path to black is $PyInterpreterDirectory$/black.
Open External tools in PyCharm/IntelliJ IDEA
On macOS: PyCharm -> Preferences -> Tools -> External Tools
On Windows / Linux / BSD: File -> Settings -> Tools -> External Tools
Click the + icon to add a new external tool with the following values:
Name: Black
Description: Black is the uncompromising Python code formatter.
Program: <install_location_from_step_2>
Arguments: "$FilePath$"
Format the currently opened file by selecting Tools -> External Tools -> black.
Alternatively, you can set a keyboard shortcut by navigating to Preferences or Settings -> Keymap -> External Tools -> External Tools - Black.
Optionally, run Black on every file save:
Make sure you have the File Watchers plugin installed.
Go to Preferences or Settings -> Tools -> File Watchers and click + to add a new watcher:
Name: Black
File type: Python
Scope: Project Files
Program: <install_location_from_step_2>
Arguments: $FilePath$
Output paths to refresh: $FilePath$
Working directory: $ProjectFileDir$
Uncheck “Auto-save edited files to trigger the watcher” in Advanced Options
To format Python files with Black, I followed this guide, which also uses File Watcher:
https://black.readthedocs.io/en/stable/editor_integration.html
Since version 2020.1, you can activate Run on save for files directly in the Preferences of the Prettier plugin:
I thought there was something like that in IntelliJ, but I can't find it. The only clean-up that happens at save is that white space at the ends of lines is removed. I thought I had to specify that behavior at one point, but I don't see anything related at this point.
If it's about Prettier, just use a File Watcher :
references => Tools => File Watchers => click + to add a new watcher => Prettier
https://prettier.io/docs/en/webstorm.html#running-prettier-on-save-using-file-watcher