Am 23.07.2011 04:29, schrieb Tim Chase:
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)
Mostly I find it annoying that paragraph motions { } and paragraph marks
'{ '} don't stop at blank lines.
Nevertheless, here is how to get the first and last line of the current
paragraph using the marks '{ and '} :
:let firstline = nextnonblank(line("'{"))
:let lastline = prevnonblank(line("'}"))
--
Andy
--
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