N Sharma
N Sharma

Reputation: 34517

How to change Atom Keybindings

I am looking to change keybindings of Atom text editor. I am familiar with Android Studio.

Does Atom allow us to customize key bindings?

Upvotes: 21

Views: 23880

Answers (4)

Vlad
Vlad

Reputation: 999

Building on Antoine's answer. Suppose you want to set up a shortcut to some command that you can get with the Command Palette (Ctrl-Shift-p). For example, I installed a package called "Pandoc Convert", and I wanted to set up the shortcut Ctrl-r for converting current file from markdown to PDF.

Step #1: Use the Command Palette to find your command. E.g. in my example, type "convert pdf". Use mouse to go over the command (but don't click). You'll see a tooltip with the name of the command. In my case "pandoc-convert:pdf".

Step #2. Go to Edit -> Preferences -> Keybinding, and click on the link at the top of the page to "your keymap file".

Step #3. Write the following in the keymap file, and save:

'atom-text-editor:not([mini])':
  'ctrl-r': 'pandoc-convert:pdf'

(Obviously, replace the shortcut and the command with what you want.)

Done!

Note: This will overwrite the previous use of the shortcut. If you want the default behavior back, erase the stuff from the keymap file.

Upvotes: 1

Attaullah Khan
Attaullah Khan

Reputation: 370

To override existing atom keybindings, just paste the new keybinding in

~/.atom/keymap.cson

If you want emacs keybindings for atom, get all the keybindings from, https://github.com/dvorka/atom-editor-emacs-key-bindings/blob/master/keymap.cson

TO APPLY:

$ gedit ~/.atom/keymap.cson

gedit is the editor available in gnome, you can also use vi or emacs or even nano to edit.

$ vi ~/.atom/keymap.cson

$ emacs -nw ~/.atom/keymap.cson

$ nano ~/.atom/keymap.cson

modify, save & exit. Restart atom, Done!

Upvotes: 3

Jan Bodnar
Jan Bodnar

Reputation: 11657

I had conflicting key-bindings of Emmet and Line-Breaker, two essential tools for a programmer or writer. I am on Linux Debian derivative, with Atom 1.45 version.

I did not find the keymap.cson in my ~/.atom/ directory. Rather, I found keymaps in the ~/.atom/packages subdirectory.

So to resolve my issue, I had updated the ~/.atom/packages/line-breaker/keymaps/line-breaker.cson file, where I changed the key bindings.

Upvotes: 0

Antoine Amara
Antoine Amara

Reputation: 645

You have to go to Edit -> Preferences -> Keybinding. In this tab you can see your actual binding and if you want to change it, you can access to the keymap file and overcharged configuration.

To access this file you can click on the link below the "Keybindings" title.

For example, if you want to replace the CtrlShiftK by CtrlShiftY, search it in the list, click on the copy icon to copy the configuration line, and put the line into the keymap file and replace the shortcut.

For this example the new line is

'atom-text-editor:not([mini])':
  'ctrl-shift-Y': 'editor:delete-line'

This line replace ctrl-shift-K by ctrl-shift-Y. You have to relaunch Atom to apply this change.

Upvotes: 35

Related Questions