Vim, Tidy and XML - how to make them work together

Background

I use vim as my main IDE. I found that I often have to muck and view XML. Often this XML is from debugging logs or output that don't add whitespace (and why would they).

The following is my setup for a small vim filetype mapping to automatically clean up xml using HTML tidy. Another great tool.

How To

First, You'll need $HOME/.vim and $HOME/.vim/ftplugin directories.

Create them, if they don't exist:
  mkdir -p $HOME/.vim/ftplugin
Second, create a new ftplugin for xml.
   vim $HOME/.vim/ftplugin/xml.vim
Third, add mapping for tidy (I use F3)
" tidy for xml -q makes it quiet
map <F3> :%! tidy -q -i -xml % <CR>
Now when you edit a file with a type of xml, you can press F3 your xml will be tidy'd. This does require that you save the xml file somewhere first (you'll need a valid filename).

Caveats

  • I've only used this on UN*Xs OSs
  • I use vim 7.x, it will probably work on 6
  • I enable filetype support in my .vimrc with command filetype plugin indent on
  • On solaris I have to do some crazy function key mapping inside of .vimrc
End transmission :)

Comments

  1. When the lockdowns eased and privateness adjustments by Apple took impact, downloads in the 온라인카지노 category declined to pre-pandemic ranges. In 2020 Casino video games revenue grew by 47% whereas installations soared by over 60%. As individuals were locked down and real-life casinos shut down, on line casino video games on cellular made financial institution. You do have to know somewhat bit about poker hand rankings before playing in} video poker, but don’t worry because of|as a result of} you will quickly pick it up. Video poker is a lovely method to spend a while because of|as a result of} the house edge is so low.

    ReplyDelete
  2. Outsourced CNC machining has become a staple of manufacturing in some industries. Companies that produce low-volume, high-complexity work turn to the method as a way of keeping prices manageable and ensuring deadlines are met. Significant amounts of CNC milling is used in the Bunny Hat aerospace business for precision machining, tooling, and mould elements. For instance, the Airbus A350 XWB used more than 1000 different milled elements in its construction.

    ReplyDelete

Post a Comment

Popular posts from this blog

BootstrapX clickover

Template Toolkit Debugging inside of Perl Dancer

2 ways to get SQLite to put dates into columns