> 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.
You hid the real point of your question behind a URL:
> [...] I see xml can be
> indented in the following URL. However, I want to be able to indent
> xml as well when I press '--'. Does anybody if there is a way to do
> so?
>
> http://vim.wikia.com/wiki/Format_your_xml_document_using_xmllint
Vim can *indent* XML on its own, without xmllint. Which is why your
question isn't:
Q: "How can I indent XML using --?"
A: It already does.
Your question is:
Q: "How can I use -- to indent other filetypes, but have -- run xmllint
on XML files?"
Answer, from the first part of that wiki post, is to add something like
the following line:
let &l:equalprg='xmllint --format --recover -'
to either ~/.vimrc (where you need to put it in an autocmd):
au FileType xml let &l:equalprg='xmllint --format --recover -'
or ~/.vim/ftplugin/xml.vim (where you don't need the 'au FileType xml '):
let &l:equalprg='xmllint --format --recover -'
If you set that up, then '--' should just work for you. Setting
'equalprg' tells Vim that the '=' operator should use an external
program to do its work.
--
Best,
Ben
--
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