Git Product home page Git Product logo

jupyterext-text-shortcuts's Introduction

text-shortcuts

A jupyterlab extension to insert text via keyboard shortcuts.

release

Pre-requisites

Installation

jupyter labextension install @techrah/text-shortcuts

or add it through your Jupyter Lab Extensions tab.

Then, add some user shortcuts:

  • In Jupyter Lab, select Settings / Advanced Settings Editor from the menu.

  • Select the Keyboard Shortcuts tab.

  • In the User Preferences section, add your shortcuts configuration and click the "save" icon.

Here are two useful shortcuts for programming in R:

{
  "shortcuts": [
    {
      "command": "text-shortcuts:insert-text",
      "args": {
        "kernel": "ir",
        "text": "%>%",
        "autoPad": true
      },
      "keys": [
        "Accel Shift M"
      ],
      "selector": "body"
    },
    {
      "command": "text-shortcuts:insert-text",
      "args": {
        "kernel": "ir",
        "text": "<-",
        "autoPad": true
      },
      "keys": [
        "Alt -"
      ],
      "selector": "body"
    }
  ]
}

NOTE: As of version 0.1.x You do NOT need to add the above shortcuts to User Preferences unless you want to override the default behaviour. These two shortcuts are now installed by default. They can be found in Keyboard Shortcuts / System Defaults.

@techrah:text-shortcuts_default-shortcuts

Anatomy of a Text Shortcut

{
  "command": "text-shortcuts:insert-text"
}

Identifies the keyboard shortcut as a text shortcut that is intercepted by this extension.

{
  "keys": [
    "Accel Shift M"
  ],
}

keys is an array of keyboard shortcuts that activate the insertion of the text snippet. Each entry can be a combination of one or more of the following modifiers, ending with a text character. For example, "Accel Shift M" represents Command-Shift-M on macOS.

  • Accel : Command (macOS) / Ctrl (Windows)
  • Alt : Option (macOS) / Alt (Windows)
  • Shift : Shift
  • Ctrl : Control
{
  "args": {
    "kernel": "ir",
    "text": "%>%",
    "autoPad": true
  }
}
  • kernel (optional): If you specify a kernel, the shortcut will only work in notebooks that are running the specified kernel. Examples of kernel names are ir for R and ipython for Python.

  • text: This is the actual text that you want inserted.

  • autoPad: (true | false). If true, will add spacing either before, after, or both before and after so that there is a single space on each side of the text.

{
  "selector": "body"
}

CSS selector. Always use "body" for this extension.

Development

Pre-requisites

  • node 5+
  • Python 3.6+

It is strongly recommended that you set up a virtual Python environment. These instructions will assume that Anaconda is already installed.

  • Create a new virtual environment and activate it.

    conda create --name text-shortcuts
    conda activate text-shortcuts
  • Install jupyterlab

    conda install jupyterlab
  • Clone this project and in the root of the project folder, install dependencies with the JupyterLab Package Manager

    jlpm
  • Install the extension

    jupyter labextension install . --no-build
  • Start up jupyter lab in watch mode. Don't forget to activate your virtual environment. If you want to use a different browser for development, specify that with the --browser switch. If you want to use a custom port, specify that with the --port switch.

    conda activate text-shortcuts
    jupyter lab --watch --browser="chrome" --port=8889
  • In another terminal, run the TypeScript compiler in watch mode.

    conda activate text-shortcuts
    jlpm tsc -w

For more information on developing JupyterLab extensions, here are some helpful resources:

Pull requests are welcome!

jupyterext-text-shortcuts's People

Contributors

dependabot[bot] avatar ryanhomer avatar techrah avatar yoshinobu-ishizaki avatar

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.