Skip to content
Ryan Jones edited this page Aug 4, 2015 · 7 revisions

Atom-Macros wiki!

This is the place to share your macros and your experiences with this plugin...

Examples, included in the source

Motion Commands

Find Next Occurrence of Word Under Cursor

This one is very similar to Vim's * command.

findWordUnderCursor = (direction) ->
    if !getActiveTextEditor().getSelection().getText()
        dispatchEditorCommand 'editor:select-word'
    dispatchEditorCommand 'find-and-replace:use-selection-as-find-pattern'
    dispatchEditorCommand direction

@findNextWordUnderCursor = ->
    findWordUnderCursor 'find-and-replace:find-next'

@findPreviousWordUnderCursor = ->
    findWordUnderCursor 'find-and-replace:find-previous'

Typing macro

Insert text into the current file

# keymap.cson
'atom-text-editor:not([mini])':
  'cmd-p': 'macros:insert'
# macros.coffee
@insert = ->
  editor = getActiveTextEditor()
  editor.insertText("this text will be inserted into your current editor")