Pipes content of files to a node repl whenever they change and adds many more features to enable a highly interactive coding experience.
Pipes content of files to a node repl whenever they change to enable a highly interactive coding experience.
Adds keymaps, doc access, vim binding and maps and prints highlighted source of functions right in the repl.
Check out the replpad home page for demos and tutorials.
rootand all subdirectories and sources a file to the repl once it changes
dox()function that is added to every core function, i.e.
dox()function that is added to every module installed via npm, i.e.
srcproperty that is added to every function, i.e.
requireto work for the file that is being sourced
module.exportsof last sourced file as
$replin order to allow further customizations
Table of Contents generated with DocToc
npm install -g replpad
path/to/root is omitted then no files are watched.
replpad . watches current directory and all sub directories.
You can use replpad inside of your application and specify repl start options:
var replpad = require'replpad';var repl = replpadprompt : 'my-prompt >'input : processstdinoutput : processstdoutignoreUndefined : trueuseColors : trueuseGlobal : trueterminal : true;
Some commands were added to the built in
repl commands. Here is a list of all of them:
pad > .help.append Appends the last entered parsable chunk of code or the last line to the last file that was sourced in the repl.clear Break, and also clear the local context.compact [on] Toggles if code is compacted before being sourced to the repl.depth  Sets the depth to which an object is traversed when printed to the repl.exit Exit the repl.help Show this list of repl commands.hidden [off] Set whether hidden properties are included during traversal of an object that is printed to therepl.highlight [off] Toggles if syntax highlighted code is printed to the repl before being sourced.load Load JS from a file into the REPL session.pack Load your package.json dependencies and devDependencies into the repl context.save Save all evaluated commands in this REPL session to a file
Note: commands that toggle a setting like
.compact take a second parameter:
on|off. If it is ommitted the state
is toggled, i.e if it was
on it is turned
off and vice versa.
Note: when code is syntax highlighted, it is still followed by the compacted code which is necessary in order to have the repl evaluate it.
You can add commands to the repl in real time via
$repldefine'sayhi'help: 'Says hi via .sayhi'console.log'Hi!'
Ctrl-Lclears the terminal
Ctrl-AAppends the last entered parsable chunk of code or the last line to the last file that was sourced in the repl.
.append command or the append keyboard shortcut is executed,
replpad will attempt to find a parsable chunk
of code to append. If the last line is parsable or no parsable chunk is found, it will append the last line.
Assume we entered:
2 + 3var a = 2;return a;
foo will be appended. This is
makes more sense than appending just
} for instance.
Additionally the code is reformatted with 2 space indents.
Plugins can be enabled/disabled in the lower portion of the replpad config file (default.
The following plugins are available.
If enabled, a subset of vim bindings are added to
replpad via readline-vim.
Consult its readme for available vim bindings.
replpad allows you to specify keymaps.
imap is used to map keys in insert mode and
nmap to map keys in normal mode.
// map 'ctrl-t' to 'esc', allowing to switch to normal mode via 'ctrl-t'$replimap'ctrl-t' 'esc';// go forward in history via 'ctrl-space' in normal mode$replnmap'ctrl-space' 'j'
You can list all registered mappings via:
You can also declare mappings to be applied at startup by including them inside the map section of your config file as explained in configuring replpad.
Mappings are limited by what the underlying nodejs
readline supports. Consult this
section for more information.
In general I found that only a few mappings in
normal mode have the desired effect. In
insert mode things are
If enabled, it will match parens, braces, brackets and quotes by jumping the cursor to the matching token emacs style.
replpad is fully configurable.
When launched for the first time it creates a config file at
~/.config/replpad/config.js. Initially this is a copy of
the default-config, but you can edit it to
change these defaults.
Reading the comments in that file should give you enough information to tweak it.