On 06/01/2015 06:25 p.m., Tim Chase wrote:
> On 2015-01-06 17:50, Cesar Romani wrote:
>> I have a text in which all lines end in numbers, like in a table of
>> contents. The numbers are supposed to be in ascending order.
>> I'd like to write a script which would highlight the first number
>> out of order.
>
> While it's not quite highlighting them, you can mark the lines
> somehow. I like to indent them, but you can also prepend/append some
> other information to the line.
>
> :g/\d\+/if getline('.')+0> getline(line('.')+1)+0 | sil!> | endif
>
> For this example, the whole line is just the number. You'd have to
> tweak the getline(...) by wrapping it in something that extracts just
> the number from whatever format of string your lines contain.
>
> The "sil!>" is what indents the lines in question. Feel free to
> modify as you see fit.
Thanks Tim,
I modified it to:
g/\d\+$/if matchstr(getline('.'), '\d\+$')+0 >
matchstr(getline(line('.')+1), '\d\+$')+0 | sil! > | endif
The thing is that you cannot use submatch(0) on it. Otherwise it works
fine.
Best regards,
--
Cesar
--
--
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.
Tuesday, January 6, 2015
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment