Vim Tips Wiki

Vim as XML Editor

Revision as of 14:14, December 22, 2013 by (Talk)

1,619pages on
this wiki

{{TipImported |id=583 |previous=582 |next=584 |created=2003 |complexity=intermediate |author=Tobi script at xmledit, but remember to add "syntax on" to your .viabhor associating file extensions with content-types (which makes sense given your background). However, in a Windows environment I find it very convenient to use file extensions and most Windows users are probably used to this idea anyways... .doc files are Word, .xls is Excel, etc.

Since you know the command line argument it isn't too hard to create the file associations. To set up (for example) an association for xmlstar on Windows 2000 you do the following:

  • Open up "My Computer"
  • Go to Tools -> Folder Options -> (tab) File Types
  • Find XML in the list (you can substitute any extension here)
  • Under "Details" in the box below see if "Advanced" is an option. If it is not, then write down what the current program name is and hit "Restore"
  • Under "Details" choose "Advanced"
  • Select the "New" button
  • In the "Action" box this is what shows up in the context menu. A good name here is XMLSTAR.
  • In the "Application used to perform this action" box you type the following:
cmd.exe /k "C:\path\to\xmlstar\xml.exe -flags_go_here %1" but you replace the flags_go_here with whatever flags you want.

If you want to just check the wellformedness of the xml document then from the vi editor you can use

let g:xml_syntax_folding=1
au FileType xml setlocal foldmethod=syntax

Hint: If no folds are found, make sure syntax highlighting is on.

Around Wikia's network

Random Wiki