Friday, July 22, 2011

Re: detecting first and last line of the current paragraph

On 07/22/2011 05:59 PM, Jose Caballero wrote:
> So far, that is the best solution I have. It is quite ugly, but seems to
> work...
>
> function Comment()
> let firstline = search('^\s*$', 'bnW') + 1
> let lastline = search('^\s*$\|\%$', 'nW', line('$'))
> if lastline != line('$')
> let lastline = lastline - 1
> endif
> for linenum in range(firstline, lastline)
> let oldline = getline(linenum)
> let newline = '#'.oldline
> call setline(linenum, newline)
> endfor
> endfunction

Could this be adequately writen as

function! Comment()
'{,'}s/./#&
endfunction

for a one-line solution? This does slightly tweak your setup in
that, if the line contains purely white-space, it's not
considered a paragraph break (and thus not found by the '{ and '}
marks)

-tim


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