Sublime Forum

Simple toggle to show/hide line numbers

#1

Generally I prefer not to see line numbers in the left margin of ST. But a few times a week, a need arises to show them temporarily. Currently that means a trip to Preferences > Settings and back.

Would be nice if hiding/showing the line numbers could be a normal “View” menu item, along with show/hide for Minimap, Tabs, etc. Or maybe a click on the line number in the status bar could show/hide.

0 Likes

Switch line numbers show/hide
#2

A Packages/User/Main.sublime-menu would do exactly this for the active view.

[
	{
		"id": "view",
		"children":
		[
			{
				"caption": "Show Line Numbers",
				"command": "toggle_setting",
				"args": {
					"setting": "line_numbers"
				},
				"checkbox": true
			}
		]
	}
]
3 Likes

#3

Thank you @deathaxe, works great!

0 Likes

#4

Sorry I am a newby… I am using Sublime build 4169 on a mac, Sonoma 14.5.

I copied and pasted the text above in file “Main-sublime-menu” and I saved the file in directory:

~/Library/Application Support/Sublime Text 3/Packages/User

But nothing happens; in particular, “View” does not contain any “Show line numbers” menu item.

I tried several filename variants, e.g., “Main-sublime-menu-settings” and “Main-sublime-menu.settings” as well as other directories “Packages”, etc.

Wouldn’t it be nice if there was some friendly way (a “package” installed by default?) that would allow users to find and modify any settings in a simple way?

—Frustrated Max

0 Likes

#5

As outlined above, the filename is Main.sublime-menu (filename Main, extension sublime-menu).

0 Likes

#7

Thanks; it works now! (I had overlooked the “.” in filename)

0 Likes