• Stars
    star
    166
  • Rank 227,748 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 8 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

macros support for VS Code

Macros

Brings simple, powerful custom macros support to VS Code. Made with <3 by geddski

See also Level up your Coding with Macros

Create Custom Macros

Create your own custom macros by adding them to your settings.json (Code|File > Preferences > User Settings)

For example:

"macros": {
    "commentDown": [
        "editor.action.copyLinesDownAction",
        "cursorUp",
        "editor.action.addCommentLine",
        "cursorDown"
    ]
}

This macro creates a copy of the current line, comments out the original line, and moves the cursor down to the copy.

Your macros can run any built-in VS Code action, and even actions from other extensions. To see all the names of possible actions VS Code can run, see Default Keyboard Shortcuts (Code|File > Preferences > Keyboard Shortcuts)

Give your macros names that briefly describe what they do.

Add Keybindings to Run your Macros

in keybindings.json (Code|File > Preferences > Keyboard Shortcuts) add bindings to your macros:

{
  "key": "ctrl+cmd+/",
  "command": "macros.commentDown"
}

Notice that macros.my_macro_name has to match what you named your macro.

Passing Arguments to Commands

Many commands accept arguments, like the "type" command which lets you insert text into the editor. For these cases use an object instead of a string when specifying the command to call in your settings.json:

"macros": {
  "addSemicolon": [
    "cursorEnd",
      {"command": "type", "args": {"text": ";"}}
  ]
}

Executing Snippets as part of a Macro

Macros can also execute any of your snippets which is super neat. Just insert the same text that you would normally type for the snippet, followed by the insertSnippet command:

"macros": {
  "doMySnippet": [
    {"command": "type", "args": {"text": "mySnippetPrefixHere"}},
    "insertSnippet"
  ]
}

License

MIT

Known Issues

Doesn't currently add macros to command pallete (have to use keybindings).

Release Notes

1.0.0

Initial release of Macros

More Repositories

1

csstyle

MOVED TO https://github.com/csstyle/csstyle a modern approach for crafting beautifully maintainable stylesheets
CSS
851
star
2

overmind

Easy module isolation and lazy loading for Angular apps
JavaScript
505
star
3

grunt-release

Release a new version of your Node-based project
JavaScript
390
star
4

amd-testing

testing AMD modules client and server side
JavaScript
124
star
5

wrapjs

RequireJS plugin for wrapping regular scripts as AMD modules
JavaScript
114
star
6

overwatch-hero-picker

Let's build the overwatch hero picker UI with CSS grid & flexbox
CSS
39
star
7

zelda-inventory

Let's build the Zelda: Breath of the Wild inventory UI with web tech
HTML
26
star
8

lessless

compile your project's LESS into CSS and update <links>
JavaScript
24
star
9

play-crank

playing around with crank and friends
TypeScript
9
star
10

richmodels

potential replacement for ngResource in Angular 2
JavaScript
6
star
11

grunt-clear

Grunt task for clearing your terminal.
JavaScript
5
star
12

jsvars-loader

webpack loader for sharing styles in both JS and CSS
JavaScript
5
star
13

cinch.js

Picks up where your micro templating left off.
JavaScript
4
star
14

ng-workshop

Launch Series Tutorial
4
star
15

grunt-symlink

Grunt plugin for creating project symlinks during your build
JavaScript
3
star
16

grip.js

grips and databinding for backbone views
JavaScript
2
star
17

NativeWeb

A demo application built using Native Web ideals, technologies, and best practices.
JavaScript
2
star
18

twilio

test for twilio
1
star
19

grunt-messageformat

JavaScript
1
star
20

photobooth

Domo hack night project
JavaScript
1
star
21

test

1
star
22

servo

1
star
23

buster-core

JavaScript
1
star