Skip to content

Instantly share code, notes, and snippets.

@nelstrom
Created February 18, 2014 18:00
Show Gist options
  • Save nelstrom/9076232 to your computer and use it in GitHub Desktop.
Save nelstrom/9076232 to your computer and use it in GitHub Desktop.
An autocommand to set up pandoc to reformat HTML with Vim's `gq{operator}` command.
function! FormatprgLocal(filter)
if !empty(v:char)
return 1
else
let l:command = v:lnum.','.(v:lnum+v:count-1).'!'.a:filter
echo l:command
execute l:command
endif
endfunction
if has("autocmd")
let pandoc_pipeline = "pandoc --from=html --to=markdown"
let pandoc_pipeline .= " | pandoc --from=markdown --to=html"
autocmd FileType html setlocal formatexpr=FormatprgLocal(pandoc_pipeline)
endif
@nelstrom
Copy link
Author

The FormatprgLocal() function is based on the code attached to this vim-fish issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment