ThisCalculator

Everyday

Display Line Numbers? How to Show Them in 5 Editors

Updated · Standard formula, shown below

This guide explains how to turn on line numbers in the most common code editors and text editors, and what to do when the setting is not where you expect it. You will get the exact menu paths for Visual Studio Code, Notepad++, Sublime Text, Vim, and Windows Notepad, plus answers to common questions like whether line numbers affect printing or performance.

Why Line Numbers Matter

Line numbers are not just decoration. They let you jump to a specific line when an error message says “error on line 42,” they make code review conversations concrete (“look at line 87”), and they help you spot missing brackets or repeated blocks when you are scanning a long file. For anyone learning to code, line numbers also provide a sense of scale: a 500-line file is very different from a 5,000-line file, and seeing the numbers scroll by makes that obvious.

Most editors have line numbers on by default, but some (like Notepad) do not, and many people accidentally turn them off with a stray keyboard shortcut. The fix is usually a single menu item or a toggle in settings, but the location varies a lot between programs.

How Line Numbers Work in Different Editors

Every editor stores the line number setting separately, and some let you customize the appearance (font, color, whether the gutter is always visible). Here are the current mainstream options:

  • Visual Studio Code – Open the Settings (Ctrl+, or Cmd+,), search for “line numbers”, and change the “Editor: Line Numbers” option from “off” to “on” or “relative”. The “relative” mode shows the distance from your cursor, which is handy for block selections.
  • Notepad++ – Go to View > Show Symbol > Show Line Numbers. A checkmark appears when it is on. The setting is per-file, so you may need to re-enable it for each new tab.
  • Sublime Text – Open View > Show Line Numbers. It stays on until you turn it off, and the setting is global (not per-file).
  • Vim – Type :set number in normal mode. To make it permanent, add set number to your .vimrc file. Use :set nonumber to hide them temporarily.
  • Windows Notepad – As of Windows 11, Notepad does not have a line number toggle in the menu. You can see the current line and column in the status bar (enable it via View > Status Bar), but to get a numbered gutter you need a different editor or a plugin.

How to Choose the Right Setting

If you are just starting out, turn line numbers on and leave them on. They cost nothing and give you a reference point. If you are doing a lot of block editing (selecting 10 lines at a time), try “relative line numbers” in VS Code or Vim, because they show you exactly how many lines you are moving. If you are presenting code on a projector, you might turn them off to reduce visual clutter, but most people keep them on.

For printed code, line numbers can be useful for classroom handouts, but they can also make long lines wrap awkwardly. Check your editor’s print settings – many editors have a separate “print line numbers” checkbox that is independent of the on-screen setting.

Common Problems and Fixes

The most common issue is that line numbers disappear after an update or a settings reset. Here is what to try:

  • Check the View menu first – many editors put the toggle there.
  • If you use VS Code, make sure you are not in “Zen Mode” (Ctrl+K Z), which hides the entire interface, including the gutter.
  • In Vim, line numbers can be hidden by a plugin or by a previous command. Run :set number again, and check your .vimrc for set nonumber.
  • If you are using a remote editor (like VS Code Remote SSH), the setting is on the remote machine, not your local one. Change it in the remote window.
  • Some editors have a “minimap” or “code map” that shows a miniature view of the file – that is not a substitute for line numbers, and it can be toggled separately.

Line Numbers vs. Gutter Icons

The area where line numbers appear is called the “gutter”. In many editors, the gutter also shows breakpoints (red dots), fold arrows, and git change indicators. If you accidentally hide the entire gutter, you lose line numbers too. In VS Code, the setting is “Editor: Gutter” – make sure it is not disabled. In Sublime, the gutter is always on when line numbers are on, but you can hide icons separately.

Performance and Large Files

Line numbers themselves do not slow down editing, even for files with hundreds of thousands of lines. The editor has to calculate the width of the gutter (e.g., 5 digits vs. 6 digits), but that is trivial. If your editor is sluggish on a huge file, the cause is usually syntax highlighting or the minimap, not the line numbers. You can turn off those features and keep line numbers on.

Alternatives to Line Numbers

If you need to reference a specific location but do not want a permanent gutter, you can:

  • Use Ctrl+G (or Cmd+G) in most editors to jump to a line number without seeing them all.
  • Use a status bar that shows the current line and column (Notepad, many editors).
  • Use bookmarks or marks (in Vim, ma sets a mark, 'a jumps to it).
  • Use a search function that returns line numbers in results (most editors show them in the search panel).

Frequently Asked Questions

Do line numbers affect printing?

In most editors, the on-screen line number setting is separate from the print setting. For example, Notepad++ has a “Print” dialog with its own “Print line numbers” checkbox. VS Code does not print line numbers by default, but you can enable them in the print options. Check your editor’s print preview before printing a long file.

Can I make line numbers start at a number other than 1?

Some editors allow this, but it is rare. Vim has :set numberstart=100, and some IDEs (like IntelliJ) allow you to set a starting line number. Most simple editors do not. If you need this for a specific format (like code snippets in a book), you may need a plugin or a different editor.

Why do line numbers disappear when I copy and paste?

Line numbers are part of the editor’s display, not the text itself. When you copy code, the numbers are not included. If you want to include them in a screenshot or a document, use a screenshot tool or a code formatting tool that adds line numbers (like “Format Code” in Word or a Markdown code block with line numbers).

Is there a keyboard shortcut to toggle line numbers?

Many editors do not have a default shortcut, but you can assign one. In VS Code, open Keyboard Shortcuts (Ctrl+K Ctrl+S) and search for “toggle line numbers”. In Notepad++, you can use the Settings > Shortcut Mapper to assign a key. Vim uses :set number! to toggle.

Do line numbers count blank lines?

Yes, every line in the file counts, including empty lines. If you delete a blank line, all numbers below it shift up. This is standard behavior in all editors. Some editors have a “blank lines” display mode that shows a special character, but the line count always includes them.

Why does my editor show line numbers in a different color?

Most editors let you customize the gutter color and font. In VS Code, you can change “Editor Line Number” colors in the settings (search for “lineNumbers” in the JSON settings). In Notepad++, you can change the gutter background in Style Configurator. The default is usually a gray or dark color to keep the numbers unobtrusive.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.