In a script like this:
function! s:myfunction() range
echo a:firstline
echo a:lastline
echo line("'<")
echo line("'>")
endfunction
command! -range myfunction :call s:myfunction()
When I run the command and try to get the start and end lines of the
visual
selected range, a:firstline and a:lastline always give me the line I
was on
when the command was executed. The '< and '> give me the lines of the
range,
but if I execute the command again with no visual selection they give
me the
visual range that was selected the last time.
I'd like to run a function on the whole file (%) if not in visual
mode, or
use the first and last selected lines to run it on a range if a visual
block
is selected. My script now uses getline(1, $) at one point, and I'd
like to
be able to replace those with the first and last selected lines if
there is
a selection.
What's the best way to do this? I'm using Vim 7.1 on Linux (though
would
like it to work on any platform with 7.1+)
Thanks,
Nathan
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---