Giter Club home page Giter Club logo

atom-eval-and-replace's Introduction

eval-and-replace

Build Status

Execute CoffeeScript, JavaScript or Shell code from the Atom editor and replace the code with the result.

calc

calc

calc

calc

Install

apm install eval-and-replace

Commands

Commands Description Default keybinding
eval-and-replace:coffee Executes selected CoffeeScript code ctrl-shift-e ctrl-shift-c or ctrl-k ctrl-e
eval-and-replace:js Executes selected JavaScript code ctrl-shift-e ctrl-shift-j
eval-and-replace:shell Executes selected Shell code ctrl-shift-e ctrl-shift-s

Be careful with eval-and-replace:shell; nobody will prevent you from executing rm -rf /!

Shell environment variables

When executing shell code with eval-and-replace:shell you have access to these variables:

  • FILE_PATH: path to of the currently opened file
  • FILE_NAME: name of the currently opened file
  • PROJECT: path to the Atom project

CoffeeScript / JS Context

CoffeeScript / JS code is executed in its own context, this means you can only use ECMAScript functions (i.e. norequire). But the same context is used for all selections, so you can reuse variables. Additionally you have access to these functions and variables:

  • i, j, n, x, y, z: initialized with 0
  • filePath: path of the opened file
  • fileName: name of the opened file
  • project: path of the current Atom project
  • PI: alias for Math.PI
  • E: alias for Math.E
  • random(): alias for Math.random()
  • pow(): alias for Math.pow()
  • sqrt(): alias for Math.sqrt()
  • abs(): alias for Math.abs()
  • sin(): alias for Math.sin()
  • cos(): alias for Math.cos()
  • tan(): alias for Math.tan()
  • floor(): alias for Math.floor()
  • ceil(): alias for Math.ceil()
  • round(): alias for Math.round()

License

This project is licensed under the terms of the MIT license. A copy of the license can be found in the root directory of the project in the file LICENSE.md.

atom-eval-and-replace's People

Contributors

moritzkn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.