4

I have installed VIM on Windows XP . I want to format XML files using the GUI / command line ? How to do that ?

I went though this post but where to enter that command gg=G from the gui?

Community
  • 1
  • 1
Geek
  • 26,489
  • 43
  • 149
  • 227

2 Answers2

6

Vi(m) is a modal editor, i.e. there is input mode for text input, normal mode to jump around and manipulate the text, and command-line mode, where you enter Ex commands that start with a colon, (and some more).

The gg=G is a normal mode command; since that is the default mode, just type it after opening the XML file. For it to properly work, the filetype must have been detected, but for a default installation, that should not be a problem. You then can save the reformatted file via :w (followed by Enter), and quit Vim via :q.

Vim is a different kind of editor, and very powerful once you learn its ways. If you're interested in it, I would recommend the built-in vimtutor (%ProgramFiles%\Vim\vim73\vimtutor.bat) as a good start.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • " just type it after opening the XML file." if i do that , it is appending gg=G to the file itself – Geek Sep 25 '12 at 12:34
  • Do you use _easy Vim_; that one defaults to insert mode?! In that case, type Ctrl + L beforehand. Otherwise, you can quit insert mode via Esc or temporarily via Ctrl + O. – Ingo Karkat Sep 25 '12 at 12:48
0

Open the file in Vim and just press the characters. You don't need a special prompt for it. For example, you can also use the keys j and k to go down and up in the file.

If you want to insert new characters, you first need to go into "insert" mode by e.g. pressing i. Everything you enter now is interpreted as ordinary content input. If you want to leave insert mode, press ESC key and return to command mode.

Besides insert and command mode, there are a few more modes. You can access a command line by pressing : while you are in command mode. You can enter visual mode by pressing v while you are in command mode.

And just in case you are lost and want to leave vim, go from command mode to the command line by pressing : and enter q followed by return or just press ZZ while in command mode ;-)

Sebi
  • 8,323
  • 6
  • 48
  • 76