sponsor Vim development Vim logo Vim Book Ad

filter : apply filters to text, by filetype

 script karma  Rating 7/3, Downloaded by 745  Comments, bugs, improvements  Vim wiki

created by
Michael Goerz
 
script type
utility
 
description
You can filter text in vim by executing the following command
:%!filter_executable
With an appropriate collection of filters, this feature can help to format text or source code, pretty print, or do advanced editing.
However, each filter has to be in your $PATH (unless you want to specify the path manually), and you have to remember the name of the program.
Also, if you have many filters, organizing them can be complicated. You may be tempted to give them long names, or you may be feeling that you end up clogging your $PATH with numerous filters that you only use in rare situations.

This plugin helps to solve this problem. You maintain your filter scripts inside of your vim folder, in a folder 'filters' with subfolders per filetype (~/.vim/filters/all for filters that are always available).

You can then apply a filter both with an Ex command (:Filter) and with a shortcut (\f in normal mode, <C-L>f in insert mode, by default). The plugin looks in ~/.vim/filters for filter scripts appropriate to the file type, and allows you to select one, interactively. The given current range is then filtered through the script.
 
install details
Put filter.vim inside of your plugins folder
Create the folders ~/.vim/filters, and  ~/.vim/filters/all.
Organize any filter scripts that you have by filetype and put them in ~/.vim/filters (e.g. ~/.vim/filters/tex, ~/.vim/filters/mail, ...)
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
filter.vim 1.1 2009-10-24 6.0 Michael Goerz you can now give additional command line flags to your filter
filter.vim 1.0 2009-10-24 6.0 Michael Goerz Initial upload
ip used for rating: 3.237.189.116

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github