I'm trying to find a command to indent an XML file in vim/gvim.
Despite all the googling, I couldn't find any. Does it exist ?
For ex. from
<?xml version="1.0" encoding="ISO-8859-1"?><BOOK><TITLE>How do you
indent?</TITLE><AUTHOR><NAME>Kennedy</NAME><FIRSTNAME>Dick</
FIRSTNAME></AUTHOR></BOOK>
I'd like to get
<?xml version="1.0" encoding="ISO-8859-1"?>
<BOOK>
<TITLE>How do you indent?</TITLE>
<AUTHOR>
<NAME>Kennedy</NAME>
<FIRSTNAME>Dick</FIRSTNAME>
</AUTHOR>
</BOOK>
simply by doing something like ":indent all" or ":1,$ indent"
or something similar...
Is it possible ?
Thanks.
Sp
> simply by doing something like ":indent all" or ":1,$ indent"
> or something similar...
In normal mode, it is the = operator:
gg=G
--
Patrick Texier
vim:syntax=mail:ai:ts=4:et:tw=72
:%s/></>\r</g
gg=G
m.
--
LaTeX + Vim = http://vim-latex.sourceforge.net/
Vim Universal Templates: http://vim.sf.net/script.php?script_id=1078
CLEWN - http://clewn.sf.net
I use a utility called tidy to format XML.
It is a UNIX program which has been ported
to win32. I have forgotten where I obtained
the port of it which I use. Google for
tidy.exe.
It requires a config file. I call mine
tidyXML.txt. It contains:
char-encoding: utf8
indent: auto
input-xml: yes
output-xml: yes
wrap: 132
indent-spaces: 4
markup: yes
quiet: yes
show-warnings: yes
numeric-entities: yes
quote-marks: yes
quote-nbsp: yes
quote-ampersand: no
break-before-br: no
uppercase-tags: no
uppercase-attributes: no
I then execute it with a small script in
a file called tidyXML.vim. This file contains:
%!C:/Bin/tidy.exe -config C:/Bin/Scripts/tidyXML.txt
To execute it, from within gvim, I use:
:so C:\Bin\Scripts\tidyXML.vim
You will need to read the documentation for tidy and
make the modifications you require. Also you will need to
change the paths to the files.