• Stars
    star
    184
  • Rank 209,187 (Top 5 %)
  • Language
    Vim Script
  • License
    MIT License
  • Created over 12 years ago
  • Updated over 2 years ago

Reviews

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

Repository Details

Send a vim buffer through a command and instantly see the output.

Vim Pipe - A Productivity-Boosting Plugin

Do you do this?

        hack <---------- alt-tab <---------- react
          |                                    |
+-------------------+                +-------------------+
| code code         |                | result result     |
| code              |                | result            |
|                   |                |                   |
|                   |                |                   |
|                   |                |                   |
|                   |                |                   |
|                   |                |                   |
+-------------------+                +-------------------+
          |                                    |
         :w -----------> alt-tab ---------> invoke

This plugin lets you do this instead:

+-------------------+
| code code         |
| code              |---------\
|                   |         |
|-------------------|   <LocalLeader>r
| result result     |         |
| result            |<--------/
|                   |
+-------------------+

Which saves tonnes of time. It's even faster than using screen or tmux.

It's useful for developing SQL queries, fast HTML previews, markdown-checking, and anything that needs to pass through a shell command while you develop.

Detail

You associate a shell command with your file, something that will take your buffer on STDIN and show the result on STDOUT. For example, if you're editing an SQL query, that command might be psql mydatabase.

Having done that, <LocalLeader>r will run the current buffer against that command and show you the results. You no longer need to save-switch-execute-switch, which makes life faster and easier.

Installation

  • Install Pathogen. (You're already using Pathogen, right?)
  • Clone this project into ~/.vim/bundle/vim-pipe.
  • Set a b:vimpipe_command variable for your buffer. The easiest way is to add a let command in ~/.vim/ftplugin/<filetype>.vim. For example:
" In ~/.vim/ftplugin/sql.vim
let b:vimpipe_command="psql mydatabase"
" In ~/.vim/ftplugin/markdown.vim
let b:vimpipe_command="multimarkdown"

See below for various examples.

Usage & Tips

Once b:vimpipe_command is configured, type <LocalLeader>r to get the list results. There's no need to save the file first. It works on the current buffer, not the contents on disk.

You can set g:vimpipe_silent=1 to disable runtime information in the output window.

PostgreSQL

" In ~/.vim/ftplugin/sql.vim
let b:vimpipe_command="psql mydatabase"

See also vim-postgresql-syntax.

Oracle

If you have an OPS$ login, it's as simple as:

" In ~/.vim/ftplugin/sql.vim
let b:vimpipe_command="sqlplus -s /"

HTML

This is only text-based, obviously, but can still speed up initial development.

" In ~/.vim/ftplugin/html.vim
let b:vimpipe_command="lynx -dump -stdin"

JavaScript

I usually run JavaScript in a browser, so I bind vim-pipe to JSLint, for code-quality checking on-the-fly.

" In ~/.vim/ftplugin/javascript.vim
let b:vimpipe_command='jslint <(cat)'

Note: JSLint doesn't accept input on STDIN, so this configuration uses bash's virtual file support. <(cat) takes the STDIN and re-presents it to look like a regular file.

JSON

I find attaching vim-pipe to a pretty-printer useful for development:

" Vim doesn't set a FileType for JSON, so we'll do it manually:
" In ~/.vimrc
autocmd BufNewFile,BufReadPost *.json setlocal filetype=javascript.json

" In ~/.vim/ftplugin/javascript.vim
" Requires that you have Python v2.6+ installed. (Most *nix systems do.)
let b:vimpipe_command="python -m json.tool"

Markdown

Fast-preview the HTML:

" In ~/.vim/ftplugin/markdown.vim
let b:vimpipe_command="multimarkdown"
let b:vimpipe_filetype="html"

Or combine wth the HTML tip to preview the rendered result:

" In ~/.vim/ftplugin/markdown.vim
let b:vimpipe_command="multimarkdown | lynx -dump -stdin"

MongoDB

Is there an official FileType for MongoDB query files? Let's say it's mongoql, for all files *.mql:

" In ~/.vimrc
autocmd BufNewFile,BufReadPost *.mql setlocal filetype=mongoql

" In ~/.vim/ftplugin/mql.vim
let b:vimpipe_command="mongo"
let b:vimpipe_filetype="javascript"

Then try editing a file called somequery.mql with something like this in:

use books;
db.book.find(null, {author: 1, title: 1 });
db.runCommand({dbStats: 1});

Help

See :help vim-pipe for more.

FAQ

What's the difference between this and :make?

The biggest difference is the way the output is presented & read. If the whole of the output is interesting, use Vim Pipe. If the only interesting part of the output is a summary of errors/warnings, use :make.

Does Vim Pipe fork/exec?

..or is there a long-lived background process?

It forks. So it works well with commands you'd invoke frequently from the command line, but not so well with something like javac, which has a (deathly) slow startup time.

Credits

Thanks to Steve Losh for his excellent guide to Vimscript, Learn Vimscript the Hard Way, and Meikel Brandmeye of vimclojure for the inspiration.

Thanks to Markus Seeger and Dhruva Sagar for their contributions.

More Repositories

1

yesql

A Clojure library for using SQL.
Clojure
1,462
star
2

remotedata

Tools for fetching data from remote sources (incl. HTTP).
Elm
253
star
3

helm-spotify

A simple Spotify-for-Emacs interface.
Emacs Lisp
180
star
4

petrol

A simple event-handling framework for ClojureScript projects.
Clojure
127
star
5

elm-export

Create Elm types and JSON decoders from Haskell source.
Haskell
116
star
6

elm-dialog

A modal library for Elm
Elm
91
star
7

evil-tabs

Integrating Vim-style tabs for Evil mode users.
Emacs Lisp
66
star
8

ob-browser

Render HTML inside Emacs' org-mode
Emacs Lisp
57
star
9

elm-exts

A toolkit of useful extensions to the core Elm libraries.
Elm
50
star
10

ob-translate

Allows you to translate blocks of text within org-mode.
Emacs Lisp
47
star
11

vim-projectlocal

Per-project .vimrc files.
Vim Script
40
star
12

formatting

A type-safe string formatting library. printf: elm style.
Elm
38
star
13

ob-mongo

Execute mongodb queries within org-mode blocks.
Emacs Lisp
36
star
14

EvilBegins

Vim user? Emacs curious? Try this...
Emacs Lisp
35
star
15

purescript-remotedata

PureScript
34
star
16

autoheadline

Generate Headlines from Hacker News
Elm
33
star
17

Cloud-Haskell-Game

A hackers' game server, written in Cloud Haskell.
Haskell
30
star
18

TrollDB

An in-memory JavaScript database that prioritises performance over everything.
JavaScript
29
star
19

AdventOfCode

PureScript solutions for Advent of Code
PureScript
16
star
20

elm-astar

The A* pathfinding algorithm for Elm.
Elm
15
star
21

wispjs-mode

An Emacs major mode for Wisp - the Lisp -> JavaScript compiler.
Emacs Lisp
13
star
22

vim-postgresql-syntax

Syntax highlighing for the output of psql.
Vim Script
12
star
23

beeline-demo

A GeoHackDay hack of the BeeLine product
Elm
11
star
24

original-lisp

The Original LISP Interpreter In Clojure
Clojure
10
star
25

vim-and-sql

Tips & Tricks for Editing SQL with Vim
Vim Script
10
star
26

purescript-formatting

A type-safe, composable, printf-alternative for PureScript.
PureScript
10
star
27

the-prize

A Game
Elm
9
star
28

BellRinger

An experiment in porting my preferred ClojureScript architecture to Haskell
Haskell
9
star
29

lunarlander

Lunar Lander, In Elm, in 90 Minutes
Elm
8
star
30

LogicPuzzles

Using Clojure's core.logic to solve a logic puzzle.
Clojure
8
star
31

langtons-ant-elm

Elm
8
star
32

bare-bones-vim

Vim London 30/4/13 Presentation
Vim Script
7
star
33

SuperBomberElf

A Mildly Multiplayer Online Blowing People Up (MMOBPU) game.
Haskell
7
star
34

hack-voting

A voting tool for hack nights.
Elm
6
star
35

Haskell-Space-Trader

90 minutes worth of Haskell hacking to create an Elite clone.
Haskell
5
star
36

elm-from-scratch

Elm
5
star
37

vim-java-sql

A very simple plugin to enable SQL syntax highlighting inside strings in a Java file.
Vim Script
4
star
38

transcodegame

A game!
Elm
4
star
39

elm-cdn

Provides quick, convenient access to the frameworks you want to grab from a CDN.
Elm
4
star
40

huffman

Huffman Encoding in Haskell
Haskell
3
star
41

wireworld

The WireWorld Cellular Automata, in Elm
Elm
3
star
42

snaplet-auth

A Snap authentication snaplet (that uses JWT instead of sessions).
Haskell
3
star
43

regexfsm

PureScript
3
star
44

Tomorrows_JavaScript_Today

PureScript
3
star
45

infinite-runner

A 90 Minute Infinite-Runner hack
Elm
3
star
46

purescript-astar

PureScript
2
star
47

maze

A Clojure Maze Generator
Clojure
2
star
48

HackerGossip

August 2015's West London Hack Night Hack
Haskell
2
star
49

snap-postgresql

Simple snaplet for Postgres
Haskell
2
star
50

compose-elm

Elm
2
star
51

lispyscript-mode

An Emacs major mode for LispyScript
Emacs Lisp
2
star
52

cascalog-demo

Playing with an idea - Hadoop to D3 via Clojure & ClojureScript
JavaScript
2
star
53

cexl

A Lisp For Clojure Exchange 2013
JavaScript
2
star
54

CLJS-Demo

Hackernews Headlines With ClojureScript
Clojure
2
star
55

markov

Markov Chains in Haskell
Haskell
2
star
56

clojurescript-from-scratch

Presentation : Getting started with ClojureScript
2
star
57

elm-build

A build tool for full Elm projects
Haskell
2
star
58

ex-spotify

Sketchbook for the course A Crash Course In Clojure
Clojure
2
star
59

formatting-types

Type level string formatting library
Haskell
2
star
60

types-all-the-way-down

Presentation - Types All The Way Down
2
star
61

Kafka_202

Kafka Beyond The Basics
TypeScript
2
star
62

space-invaders

Elm
2
star
63

kashmir

Haskell
2
star
64

history

Manage History URIs in Elm
Elm
2
star
65

export-elm

Utilities for generating Elm code from Haskell.
Haskell
2
star
66

django-urlhelper

A simple manage.py command to make it easy to query Django's URL dispatcher
Python
2
star
67

Alice-in-Markov-Chains

The January 2014 West London Hack Night Clojure Hack
Clojure
2
star
68

Slack-Echo-Bot

A basic realtime slack bot, written in Haskell
Haskell
2
star
69

ClojureScriptForScale

ClojureX 2015 Presentation
CSS
1
star
70

diamondkata

The Diamond Kata in Elm
Elm
1
star
71

elm-for-real-work

An Elm Presentation
1
star
72

anagrams

Anagrams in Haskell - West London Hack Night - April 2015
Haskell
1
star
73

grid20

Grid 20 - An interview puzzle
Haskell
1
star
74

flatland

Discount CAD
Haskell
1
star
75

logo-purescript

A PureScript free monad hack of the Logo programming languages.
PureScript
1
star
76

flowchart

Elm experiment
Elm
1
star
77

gitparse

Haskell
1
star
78

ex-web

A Crash Course In Clojure Web Project
Clojure
1
star
79

game-of-life-rust

Conway's Game of Life, In ASCII, in Rust
Nix
1
star
80

AdventOfCodeHaskell

Haskell
1
star
81

tetris

West London Hack Night - Now much Tetris in 90 minutes?
Haskell
1
star
82

elm-maze

An Elm Maze Generator
Elm
1
star
83

langtonsant

Langton's Ant, in Clojure & Quil
Clojure
1
star
84

stack365

Replicating stack issue 365
Haskell
1
star
85

knapsack-haskell

The Knapsack Problem in Haskell
Haskell
1
star
86

shen-hacks

Playing around with Shen at West London Hack Night's "Hacking Blind"
1
star
87

vim-clojure-sql

A very simple plugin to enable SQL syntax highlighting inside strings in a Clojure file.
Vim Script
1
star
88

AStar

The A* Algorithm, In JavaScript, for a West London Hack Night.
JavaScript
1
star
89

status-dashboard

Nix
1
star
90

vim-jslint

Run :make on a JavaScript file, get JSLint messages in the quickfix buffer.
Vim Script
1
star
91

hack-malawi

A quick hack, visualizing some Malawi Aid Data
JavaScript
1
star
92

logic-jigsaw

Haskell
1
star