VIM Range Range Number Registers

Is there a register or variable that contains line numbers for the selected range?

line(".") works as for the current line, but is there in the visible range?

EDIT

As indicated below, the registers '< and '> contain the start and end lines.

What I ended up doing in addition to using the above was writing a function in VimScript that takes these line numbers and executes an external command, I will 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 new to VimScript, but from what I put together in an initial Google search, the above function takes a range. Then I take the start and end line numbers and use them to execute an external github script that interacts with the Github API and / or opens a browser on the github page based on git info.

+4
source share
1 answer
  • '< and '> respectively.

    So: line("'<") and line("'>") should be what you expect

  • Besides,

     :'<,'>sort 

    to sort the last visual highlight

  • ` < to go to the beginning of the last visual selection (see also :he v_o )

  • Finally, if 'cpoptions' contains no include * , you can use :* as a synonym for :'<,'> :

     :se cpoptions-=* :*sort 
+8
source

Source: https://habr.com/ru/post/1438080/


All Articles