Thursday, October 27, 2011

Re: Shortcut to indent xml

On 2011-10-27, Peng Yu wrote:
> On Thu, Oct 27, 2011 at 1:45 PM, Gary Johnson <garyjohn@spocom.com> wrote:
> > On 2011-10-27, Ivan Sichmann Freitas wrote:
> >> > "full file indent
> >> > fun BenIndent()
> >> >   let oldLine=line('.')
> >> >   normal gg=G
> >> >   execute ':' . oldLine
> >> > endfun
> >> > "map -- :call BenIndent()<Bar>normal zz<CR>
> >> > map -- :call BenIndent()<CR>
> >>
> >> You could also just use:
> >> map -- gg=G
> >
> > Except that Peng wants the cursor to return to the original line.
> > For that I think this will work though:
> >
> >    map -- gg=G''
> >
> >> (or even =%)
> >
> > That will indent from the current location to the matching
> > 'matchpairs' character (e.g., parenthesis) or to the matching
> > b:matchword if matchit.vim is enabled.
> >
>
> But my question is how to indent XML using --? I appreciate Ivan and
> Gary for answering my question. But the answers are not what I asked.

It works fine for me.

I opened an XML file, executed "%:left" to unindent it, entered your
function definition and mapping by copying and pasting from your
message, moved the cursor to a point midway in the file, and typed "--".
The file was indented and the cursor position restored.

Maybe you have an xml.vim plugin that interferes with XML indenting.

Regards,
Gary

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment