All Projects → krisajenkins → Vim Pipe

krisajenkins / Vim Pipe

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

Labels

Projects that are alternatives of or similar to Vim Pipe

Vim As An Ide
Workshop on how to use Vim Plugins.
Stars: ✭ 1,915 (+975.84%)
Mutual labels:  viml
Wordpress.vim
Vim Plugin for WordPress Development
Stars: ✭ 164 (-7.87%)
Mutual labels:  viml
Zoomwin
Zoom in/out of windows (toggle between one window and multi-window)
Stars: ✭ 173 (-2.81%)
Mutual labels:  viml
Vimerl
A set of erlang plugins for VIM. This is not maintained, better use som modern fork of this!
Stars: ✭ 159 (-10.67%)
Mutual labels:  viml
Vim Github Comment
Comment commits on GitHub using Vim
Stars: ✭ 162 (-8.99%)
Mutual labels:  viml
Vim Subversive
Vim plugin providing operator motions to quickly replace text
Stars: ✭ 168 (-5.62%)
Mutual labels:  viml
Vim Galore
🎓 All things Vim!
Stars: ✭ 12,610 (+6984.27%)
Mutual labels:  viml
Snipmate.vim
snipMate.vim aims to be a concise vim script that implements some of TextMate's snippets features in Vim.
Stars: ✭ 2,051 (+1052.25%)
Mutual labels:  viml
Paredit.vim
Paredit Mode: Structured Editing of Lisp S-expressions
Stars: ✭ 162 (-8.99%)
Mutual labels:  viml
Vim Shell
Improved integration between Vim and its environment (fullscreen, open URL, background command execution)
Stars: ✭ 171 (-3.93%)
Mutual labels:  viml
Vim Config Python Ide
Symlink the .vim dir and the .vimrc file and start kicking ass
Stars: ✭ 159 (-10.67%)
Mutual labels:  viml
Vim Operator User
Vim plugin: Define your own operator easily
Stars: ✭ 161 (-9.55%)
Mutual labels:  viml
Vim Argumentative
Argumentative aids with manipulating and moving between function arguments.
Stars: ✭ 169 (-5.06%)
Mutual labels:  viml
Vim Markbar
Display all accessible marks and their surrounding lines in a collapsible sidebar.
Stars: ✭ 159 (-10.67%)
Mutual labels:  viml
Replacewithregister
Replace text with the contents of a register.
Stars: ✭ 174 (-2.25%)
Mutual labels:  viml
Pdv
PHP Documentor for VIM - Generates PHP docblocks
Stars: ✭ 158 (-11.24%)
Mutual labels:  viml
Stackanswers.vim
Vim plugin to fetch and display answers from Stack Overflow
Stars: ✭ 165 (-7.3%)
Mutual labels:  viml
Jshint.vim
A plugin that integrates JSHint with Vim
Stars: ✭ 177 (-0.56%)
Mutual labels:  viml
Vimconf
Extensive vimrc with super easy install and everything in the vimrc is explained!
Stars: ✭ 175 (-1.69%)
Mutual labels:  viml
Detectindent
Vim script for automatically detecting indent settings
Stars: ✭ 169 (-5.06%)
Mutual labels:  viml

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].