From 0bd5578eac4428555ecff4359274045cf9dc623d Mon Sep 17 00:00:00 2001 From: Chris Chambers Date: Thu, 12 Jul 2012 22:30:47 +0800 Subject: [PATCH] Adding support for NetCDF This adds support to edit NetCDF files, they get converted to cdl when reading and writen back to NetCDF when writing using the NCO tools. You will need netcdf installed for this to work --- README.markdown | 4 ++++ doc/afterimage.txt | 3 +++ plugin/afterimage.vim | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/README.markdown b/README.markdown index 453bd1b..5db28ac 100644 --- a/README.markdown +++ b/README.markdown @@ -17,6 +17,10 @@ Oh, and it can also handle PDFs (with Word Documents (read-only, with [Antiword](http://www.winfield.demon.nl/)), and Mac OS X plist files. +If you are more scientifically inclined it also lets you edit +[NetCDF](http://www.opengeospatial.org/standards/netcdf) files in their +CDL form. + Installation ------------ diff --git a/doc/afterimage.txt b/doc/afterimage.txt index ac87a8f..dc8695b 100644 --- a/doc/afterimage.txt +++ b/doc/afterimage.txt @@ -19,6 +19,9 @@ Word documents have their text extracted (one way) with antiword. OS X binary plists are converted to/from XML with plutil. +NetCDF files are converted to CDL with ncdump for editing and back to NetCDF +with ncgen + CUSTOMIZATION *afterimage-customization* The easiest way to provide custom handlers is to learn from the source to the diff --git a/plugin/afterimage.vim b/plugin/afterimage.vim index 872e526..22586da 100644 --- a/plugin/afterimage.vim +++ b/plugin/afterimage.vim @@ -21,6 +21,13 @@ augroup afterimage autocmd BufWriteCmd,FileWriteCmd *.ico call AfterimageWriteCmd("convert %s ico:%s") endif + " Convert NetCDF files to cdl for editing (http://www.unidata.ucar.edu/software/netcdf/) + if !exists("#BufWriteCmd#*.nc") + autocmd BufReadPre,FileReadPre *.nc setlocal bin + autocmd BufReadPost,FileReadPost *.nc if AfterimageReadPost("ncdump %s >%s") | set ft=c | endif + autocmd BufWriteCmd,FileWriteCmd *.nc call AfterimageWriteCmd("cat %s | ncgen -o %s") + endif + if !exists("#BufWriteCmd#*.pdf") autocmd BufReadPre,FileReadPre *.pdf setlocal bin autocmd BufReadPost,FileReadPost *.pdf call AfterimageReadPost("pdftk %s output %s uncompress")