Toggle Line Numbers


Loving atom so far, quite a few improvements over sublime, but I’m missing the ability to quickly toggle line numbers with a keyboard shortcut. Any way to do this or add it simply?


You have to add this code to your

atom.workspaceView.command 'line-numbers:toggle', ->

Then map the line-numbers:toggle command to a key, you can do this in the keymap.cson file:

  'f5': 'line-numbers:toggle'

I’m using F5 but you can use whatever you want.


Awesome! Thank you, glad the editor is so flexible. May be my new main choice.


Hi, It’s working like a charm. Thanks for sharing it.

But there are some deprecation messages on init.coffe file. This is the warning message:

Config::toggle is no longer supported. Please remove from your code.


atom.workspaceView is no longer available. In most cases you will not need the view. See the Workspace docs for alternatives: If you do need the view, please use atom.views.getView(atom.workspace), which returns an HTMLElement.

What I should do for fixing these issues?



You can do the same thing with:

atom.commands.add 'atom-text-editor:not([mini])', 'line-numbers:toggle', ->
  lineNumbersShowing = atom.config.get('editor.showLineNumbers')

  if lineNumbersShowing
    atom.config.set('editor.showLineNumbers', false)
  else if not lineNumbersShowing
    atom.config.set('editor.showLineNumbers', true)

[SOLVED] How to hide gutter when hiding line numbers?

Thank you for your response. It’s solved the deprecation issues. :slight_smile: