1300

How can I permanently enable line numbers in IntelliJ IDEA?


  • why don't all IDE's have the default to "yes show line numbers", how do you debug anythign without using line numbers ? - NimChimpsky
  • Most IDE's have the line number where your mouse cursor is in the status bar, but that's not too useful. Normally there is line numbers in stack traces right? In VIM you can jump to line numbers <line number>G, and Sublime Text, Ctrl+g (type in line number). What's the benifit of line numbers if you can jump straight where you want to go? - Dauh Fhauc
  • What I like the most about the line number column is that it provides an easy hit area for selecting multiple lines without having to fiddle with exact cursor placement. - Eric Cosky
  • I also can't imagine people working without line numbers switched on. And never the less you might possibly don't need it because you just click on links in stacktraces. It gives you orientation in the code and might also be usefull if you talk to someone else about fragments of it. - ccDict
  • All of you talking about clicking on stack traces are assuming that the stack trace being debugged is generated in the IDE. This is almost never the case in a real world scenario. You get a stack trace from a client and then you need to track it down. - Dan

19 답변


1370

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

enter image description here

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.

  1. On a Mac, these are named IntelliJ IDEA | Preferences...

enter image description here


  • Cntrl + Shift + a --- Then type in "show line numbers". I use cntrl+shift+a for finding most menu stuff. - Uncle Iroh
  • For the Mac new-schoolers, Android Studio > Preferences > Editor > Appearance > Show line numbers - whyoz
  • Still the same place in version 15.0... :-) - sgirardin
  • NOT there in IntelliJ 2016.x :( The Shift-Shift workaround still works though. - csvan
  • @csvan it's still there in IntelliJ 2016.1.1 under the appearance menu - Dónal

347

The question is obviously well answered already, but since IJ 13 you can enable line numbers in 2 seconds flat:

  1. Press shift twice
  2. Type "line number"
  3. The option shows in the menu and press enter to enable/disable.

enter image description here

Et voila ;)


  • This is the correct answer. Shift-Shift is all you need to know for anything IntelliJ related. Stop digging through the settings dialog people! - Daniel Alexiuc
  • This is not permanent - user3218743
  • As @user3218743 said, turning line numbers on this way is TEMPORARY. This is not the optimal solution. - Shadoninja
  • @user3218743 and @SamuelKerrien It depends on which of the one of the show line numbers you select. There is one which turns it on/off temporary and one which changes settings (with an on/off toggle at end of line) - osundblad
  • Shift then Shift should surely be written Shift, Shift not Shift+Shift. - AjahnCharles

104

There's another way, and even quicker (works for me in version 10.5)

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.

enter image description here

Please note that this only works on a per-file basis, however. Enjoy.


  • It worked like a charm in Android Studio! - Alexey Shevelyov
  • This works only for current editor window! - Vikram Dattu
  • Why did I not think of this - Derek 朕會功夫
  • This is the most temporary way of turning line numbers on. The top answer is the proper way to do this so it sticks. - Shadoninja
  • Only the current editor and current session. Removed on restarting android studio and does not show in any other windows. - Zoe

90

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.Intellij Settings search for line numbers


  • In Intellij 14 it's now File -> Settings -> Editor -> General -> Appearance -> Show line numbers. Or Search for "Line Numbers". - Radu Bompa

71

Android Studio 1.3.2 and on, IntelliJ 15 and on

Global configuration

File -> Settings -> Editor -> General -> Appearance -> Show line numbers

enter image description here


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. enter image description here


51

For InteliJ IDEA 11.0 and above
Goto File --> Settings in the Settings window Editor --> Appearance
and tick Show line numbers check box.

enter image description here


  • This exact answer has already been posted two and half years ago by Don. - Shadow Wizard
  • I looked again in the posts. They are the same, the slight difference does not justify new answer you could add comment on the existing answer saying something like "it also exist in version 11" and maybe explain this slight difference. - Shadow Wizard

30

IntelliJ 14 (Ubuntu):

See: how-do-i-turn-on-line-numbers-permanently-in-intellij-14

Permanently:

File > Settings > Editor > General > Appearance > show line numbers

Editor

For current Editor:

View > Active Editor > Show Line Numbers

Menu


29

IntelliJ IDEA 15

5 approaches


Global change

  1. File > Settings... > Editor > General > Appearance > Show line numbers

    show line numbers

  2. Hit Shift twice > write "line numbers" > Show Line Numbers (that one that has the toggle) > change the toggle to ON

    shift shift


Change for the Active Editor

  1. Right click on the left side bar > Show Line Numbers

    right click

  2. Hit Shift twice > write "line" > Show Line Numbers (the line doesn't have the toggle)

    shift shift line

  3. Ctrl + Shift + A > write "Show line" > Active Editor: Show Line Numbers > change the toggle to ON

    Ctrl Shift A


  • Casper LI mentioned that Android Studio 1.5.1 is similar with IntelliJ IDEA 15 regarding the line numbers. - ROMANIA_engineer

21

Ok in intelliJ 14 Ultimate using the Mac version this is it.

IntelliJ Idea > Preferences > Editor > General > Appearance > Show Line Numbers


  • For those who have been struggling on Mac like I was to find this, don't be tricked by the "Appearance & Behavior" Tab, Like @Shawn said, it is under the editor tab, there are multiple levels with name appearance. Also Make sure you are looking at the settings under preferences. - Unome
  • @Unome Not only Mac, Windows too. - Ajay

18

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'

enter image description here


13

Android Studio

Go to Android Studio => Preferences => Editor => General => Appearance => set Checked "Show line numbers"

enter image description here


12

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


11

Hello this is Tim from the FUTURE!!! 2011... For 9.0.4

File > Settings

In the tree view group

------------IDE Settings ---------

Click the Editor [+]

Select Appearance... Its there.


11

1st way: Go to View => Active Editor => show line numbers

enter image description here

2nd way Go to Android Studio => Preferences => Editor=> Appearance => set Checked "Show Line Numbers"

enter image description here

enter image description here


10

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:

Choosing "Preferences" on the Mac.

and within that is the "Settings" dialog shown by the Windows Intellij.


10

In IntelliJ 14 it has moved again somewhat down the menu.

Now we have it unter Editor -> General -> Appearance

enter image description here


8

Just an update for Android Studio 1.5.1 on Windows:

Go to File -> Settings -> follow picture enter image description here


7

On IntelliJ IDEA 2016.1.2

Go to Settings > Editor > General > Appearance then check the Show Line number option

enter image description here


  • Is 'Settings' in IDEA 2016.1.2 called 'preferences'? I'm new to IntelliJ, so I don't want to edit that in this Answer before asking... - cellepo
  • @cellepo Menu File > Settings - Alexis Heijmeijer

6

I add this response for IntelliJ IDEA 2018.2 - Ultimate.

Using menu

IntelliJ Idea > Preferences > Editor > General > Appearance > Show Line Numbers

enter image description here

Using Shortcuts - First way

For Windows : Ctrl+Shift+a
For Mac : Cmd+shift+a

enter image description here

Using Shortcuts - Seconde way

Touch Shift twice

enter image description here

These three methods exist since the last 4 versions of Intellij and I think they remain valid for a long time.

Linked


Related

Latest