Giter VIP home page Giter VIP logo

note-macros's Introduction

Note Macros

Heavily inspired by Foam's Daily Note feature and Jeff Hykin's code.

Intended Use

This extension was originally developed to go hand in hand with Foam.

Foam is a personal knowledge management and sharing system inspired by Roam Research, built on Visual Studio Code and GitHub.

You theoretically could also use this with other Note Taking solutions with vscode.

Installation

To install search note-macros in vscode or head to note-macros

Features

This extension was heavily inspired by Jeff Hykin's macro-commander. In addition to the functionality mentioned below you are able to use macro-commander's functionality.

Create Custom Note Macros

Create your own custom macros by adding them to your settings.json (Code|File > Preferences > User Settings). A full example can be found at settings.json

For example:

This macro creates a Weekly note in the Weekly note Directory.

{
  "note-macros": {
    "Weekly": [
      {
        "type": "note",
        "directory": "Weekly",
        "extension": ".md",
        "name": "weekly-note",
        "date": "yyyy-W"
      },
    ]
  }
}

Explanation of fields

"type": "note"

If your macro does not execute check this field first. This field was introduced to separate the existing functionality of macro-commander and my work. In the future this field will also separate the Zettelkasten functionality.

"directory": "Weekly"

The directory your note will be created.

"extension": ".md",

The extension that will be used. If not supplied this will default to markdown but can be changed.

"name": "weekly-note",

This will be the name of the note. Both the file name and note title will be effected by this.

"date": "yyyy-W"

This is the date format for your note. For additional formats please go to dateFormat. This will default to yyyy-mm-dd.

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)

Add Keybindings to Run your Macros

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

{
  "key": "ctrl+cmd+/",
  "command": "note-macros.Weekly"
}

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

Executing Snippets As Part Of A Macro

Release 0.0.1 Snippets are not functioning correctly!

I am leaving this in here in case it works for someone else. If it works for you please open an Issue to let me know.

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:

{"command": "type", "args": {"text": "mySnippetPrefixHere" }},
      "insertSnippet" 
{
  "macros": {
    "Weekly": [
      {
        "type": "note",
        "directory": "Weekly",
        "extension": ".md",
        "name": "weekly-note",
        "date": "yyyy-W"
      }
    ],
    "doMySnippet": [
      { "command": "editor.action.insertSnippet", "args": ":daily" }
    ]
  }
}

Run macro From command pallette

Simply use Ctrl+P or Alt+P depend on your os, and type Note Macros: Run A Macro then chose the macro you want to execute.

Available Commands for Macros

To list all available commands for your macros use Ctrl+P or Alt+P depend on your os, and type Macro Dev: List all the commands that can be used in macros then chose the macro you want to execute.

Roadmap

Current Release

  • Creation of completely Custom Notes

Next Release

Future

As of right now Custom Notes and Zettelkasten notes complete my initial vision of this extension. My new vision is for this extension to become a one stop shop for defining quick commands from settings.json. If you have an idea please open an Issue and we will discuss.

Issues

This extension will be extensively used and tested on Windows and Linux. I do not have access to a MacOS machine. With that being said I cannot test on Mac. If you run into any issues on any environment please open an Issue.

Credit

This extension combines the my work with Jani Eväkallio's work and Jeff Hykin's work. My vision and code would not be possible without them.

License

Note Macros is released under the MIT License.

note-macros's People

Contributors

fanlushuai avatar jevakallio avatar kneely avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

note-macros's Issues

Creating an index page for better movement

Hello, can we maintain an index along with the note creations? This could be optional specified through a parameter in the settings JSON.

So, ideally the macro steps would be:

  1. the note is created as newNoteName
  2. indexFileExists? createIndexAndAppendNewNoteName : appendNewNoteName

Index can look like:

- [[2020-11-20-Daily]]
- [[2020-11-21-Daily]]
- [[2020-11-22-Daily]]

And the settings.json can have some extra parameters like:

{
"indexing": true,
"indexFile": "index.md"
}

command '[object Object]' not found

When running a note macro via a keyboard shortcut, I get the error command '[object Object]' not found displayed. The following is the error log after the run:

[2022-05-22 05:11:05.974] [exthost] [error] Error: command '[object Object]' not found
    at S._tryExecuteCommand (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1694:3532)
    at S.executeCommand (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1694:3414)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) note-macros.weeklyNote {"value":"NeelyInnovations.note-macros","_lower":"neelyinnovations.note-macros"}

If I use the command palette to run the macro, the error is not logged or displayed. Only when using a keyboard shortcut. I have tried multiple shortcut options, and it happens with any shortcut that I use.

Allow date formatting within name

It might be a good idea to allow date formatting within the name attribute.
Use case:
This might open up more meaningful note headings like

2020-11-20-Thursday-November
...

or

2020-11-22-Saturday-November
...

Make note-macro.list-builtin-commands less intrusive

When executing the Note macros: ... commands, the "List all the commands..." seems quite intrusive -- I would not expect to see it every time I want to autocomplete "mac...".

I couldn't immediately figure out how to use it. Was it intentionally published, or a debug command for development use?

I'd consider either removing it, or if it's necessary, giving it a more subtle name that does not have the "Note macros" prefix.

Screenshot 2020-08-21 at 20 21 08

Note Macros Status

Hello, I am not using Note Macros anymore. If someone would like to take over support and development, please let me know. I will add you to this repo.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.