3
votes

Is there a way in the Atom editor to create macros (recording several keystrokes into a new keyboard shortcut)?

I'm coming from Sublime Text 3 and one feature I miss is the ability to make keyboard macros for annoying to type text.

My particular example is: I have to type <%= x %> a lot and ultimately I want the cursor to be where the "x" is so I can begin echoing out whatever variable I need to show.

I looked through a bunch of Atom packages and did not see anything quite like this. Perhaps I'm searching with the wrong terms?

1

1 Answers

3
votes

I figured out how to do this so I thought I'd share it here.

Atom comes has a feature called snippets which can somewhat act as a macro recorder. Detailed documentation can be found here https://flight-manual.atom.io/using-atom/sections/snippets/.

For my bee string snippet I added the following to the snippets.cson file.

'.source.js':
  'Bee strings':
    'prefix': 'bee'
    'body': '<%= $1 %>'

Then every time I type bee I have the option to autocomplete with <%= %>. The $1 is where the cursor will be placed. For me this is great since that's exactly where I want to be to start typing some JS code or whatnot.