Is there a register or variable that holds the line numbers for currently selected range?
line(".")
works as for the current line but is there one for in a visual range?
EDIT
As mentioned below the '<
and '>
registers hold the beginning and ending lines.
What I ended up doing in addition to using the above was writing a function in VimScript which takes those line numbers and executes an external command, I'll include it below:
function! Github(line1, line2)
execute "!github -f " . expand("%") . " -l " . a:line1 . " -n " . a:line2
endfunction
com! -range Github call Github(<line1>, <line2>)
I'm brand new to VimScript but from what I gathered from an initial google search, the above function accepts a range. I then take the beginning and ending line numbers and use them to execute the external script github
which interfaces with the Github API and/or opens a browser to a github page based on the git info.
'<
and '>
respectively.
So: line("'<")
and line("'>")
should be what you expect
Also,
:'<,'>sort
to sort the last visual selection
`< to jump to the start of the last visual selection (also see :he v_o
)
Finally, if 'cpoptions'
does not include *
, you can use :*
as a synonym for :'<,'>
:
:se cpoptions-=*
:*sort
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With