Tuesday, June 10, 2014

Re: indent versus previous line

On Tuesday, June 10, 2014 2:45:53 PM UTC+2, Tim Chase wrote:
> On 2014-06-10 04:59, Ni Va wrote:
>
> > the indentation depends on the number of "\s" in the header.
>
> > If you mean that the header is :
>
> > \s\s\sTHREE or \s\sTWO
>
>
>
> Okay, then the following one-liner should do what you describe
>
>
>
> :g/^\\s/exec 'sil! +,/^END_OF_BLOCK/'.repeat('>', strlen(matchstr(getline('.'), '\(\\s\)\+')) / 2)
>
>
>
> that finds the number of "\s" pairs in each "\s" line, then indents
>
> the following block (as ended by the "END_OF_BLOCK" line) by the
>
> that number of indentation levels. What this actually does
>
> (whether it uses tabs vs. spaces, and how many tabs/spaces those
>
> indentations are) will be controlled by your 'expandtab', 'tabstop'
>
> and 'shiftwidth' settings.
>
>
>
> The "sil!" just reduces the noise because the ">" Ex command likes to
>
> be noisy about its actions and you'll get thousands of "N lines >ed M
>
> times" messages otherwise.
>
>
>
> -tim

It works a little using \s out \\s because I have magic card I think:

:g/^\s/exec 'sil! +,/^END_OF_BLOCK/'.repeat('>', strlen(matchstr(getline('.'), '\(\s\)\+')) / 2)


In fact I got :

<some\spaces>THE_LINE_OF_THE_HEADER_THREE
OTHER DEPEND'S LINES
OTHER DEPEND'S LINES

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: